java – Invalid escape sequence (valid ones are b t n f r \ )

java – Invalid escape sequence (valid ones are b t n f r \ )

You need to escape the in the file path.

BufferedReader job = new BufferedReader 
               (new FileReader(\My Documents\JOBS\newfile.txt));

is an escape character, use \

java – Invalid escape sequence (valid ones are b t n f r \ )

If youre using eclipse, theres a setting that inserts escape chars automatically when pasting:

Window -> Preferences -> Java -> Editor -> Typing -> In String Literals -> Escape text when pasting into a string literal

Then, when something like D:EnvImagesimage1.png is in your clipboard and you paste it into eclipse, itll automatically look like this: D:\Env\Images\image1.png

Leave a Reply

Your email address will not be published.