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));
}
}