Ariel Cotton

Greenhorn
+ Follow
since Mar 24, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ariel Cotton

Yes! You were bang-on. I got it to work! Thanks a lot! Next time, I'll copy and paste.
13 years ago
Yes, but when I tried putting in double quotes, it said "filepath string cannot be resolved."
13 years ago
Hello all,

I'm trying to write a program that will allow users to type in a file path and return just the name of the file that they specified. I have the program written out, but every time I try to run it in Eclipse, it gives me the message, "string literal is not properly closed by a double quote." I think it's mostly in reference to the piece of code that says "int lastBackslash = filepathstring.lastIndexOf("\");"

Someone please help me out! Thanks.


import java.util.Scanner;

public class filepath {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Enter a pathname:");
String filepathString = input.next();
int lastBackslash = filepathstring.lastIndexOf("\");
System.out.println(filepathString.substring(lastBackslash + 1));
}
}
13 years ago