-2

I have seen this be answered on others and i have tried it but i couldn't find anything that worked for me i was looking for help.

    ArrayList<Integer> integers = new ArrayList<Integer>();
    Scanner fileScanner = new Scanner(new File("workspace\Sudoku\file"));

it keeps giving me this error "Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\)", the file location is correct by the way. i think it may be because i am using a scanner although i am not 100% sure.

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

0

You need to escape the escape character which is "\", try this:

Scanner fileScanner = new Scanner(new File("workspace\\Sudoku\\file"));
RAZ_Muh_Taz
  • 4,059
  • 1
  • 13
  • 26
0

Your string is not escaped properly.

Use:

Scanner fileScanner = new Scanner(new File("workspace\\Sudoku\\file"));
pr0gramist
  • 8,305
  • 2
  • 36
  • 48