I have a webservice running on tomcat, and want to execute some fileIO.
File f = new File(test.txt);
new BufferedReader(new FileReader(test.txt));
result:
java.io.FileNotFoundException: test.txt
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at java.io.FileReader.<init>(FileReader.java:58)
Am I missing something? Running my code as a local standalone app works as expected. But on tomcat results in exception.
you need to create the file first. A File object is actually just a representation of a file’s path, not the file itself.