-1

I am encountering this error

java.io.FileNotFoundException: C:\Users\user\Desktop\OUTPUTS\REPORT.xlsx (The system cannot find the path specified)" even though I already edited the directory/path of the file to " fileOut = new FileOutputStream("C:\Users\samuel\Desktop\REPORT.xlsx")

C:\Users\user\Desktop\OUTPUTS\REPORT.xlsx is the previous directory.

I edited it because it is a directory of another computer.

Please help me! Thank you very much.

Avnesh Shakya
  • 3,828
  • 2
  • 23
  • 31
Samuel
  • 1
  • 3
  • new FileOutputStream("C:\\Users … : you need double slashes – Dominique May 16 '18 at 07:50
  • It is not the problem. I already edited it to "C:\\Users\\samuel\\Desktop\\REPORT.xlsx" but the error says "java.io.FileNotFoundException: C:\Users\user\Desktop\OUTPUTS\REPORT.xlsx (The system cannot find the path specified)" – Samuel May 16 '18 at 07:55
  • To prevent typos, go to the correct folder in the explorer or the command prompt and use copy and paste of the complete path. Also use copy and paste for the filename. And do use double backslashes ("\\"). If you still get the exception it might be that you don't have permissions to read the file or folder. – ffonz May 16 '18 at 09:42

2 Answers2

0

in java the (\) character is used as an escape character. therefore you must use 2 together.

i.e.

C:\\Users\\user\\Desktop\\OUTPUTS\\REPORT.xlsx

  • It is not the problem. I already edited it to "C:\\Users\\samuel\\Desktop\\REPORT.xlsx" but the error says "java.io.FileNotFoundException: C:\Users\user\Desktop\OUTPUTS\REPORT.xlsx (The system cannot find the path specified)" – Samuel May 16 '18 at 07:54
  • try moving the file somewhere else, and change the path in your code, see if that makes any difference –  May 16 '18 at 07:58
0

You have tried almost most possible way, there might be problem with file then.

1) check filename is properly spelled without any space. 2) check whether filename is directory.

Refer This Stack answer for more info

Lucifer
  • 784
  • 2
  • 7
  • 20