But \U is not a valid escape character. \n is valid. It's a newline character. \t is a tab.
Since \ always tries to combine with the next character, how do you represent a \ if you want a slash?
You use 2 slashes. So, change every slash into 2 slashes.
I did that but now can I get this: Error: Could not find or load main class files.Files
Want to scan a text file in my Java script. Following a youtube video. But for some reason it keeps saying illegal escape character. And adds \ making it C:\\ instead of C:\
package Files;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Files {
public static void main(String[] args) throws FileNotFoundException{
Scanner scan = new Scanner (new File("?C:\Users\Jaap\Desktop\File.txt"));
while(scan.hasNextLine())
System.out.println(scan.nextLine ());
}
}