I always get this error when I try to run it:
IOException: java.io.FileNotFoundException: read.txt (The system cannot find the file specified)
Here is my code snippet:
try(BufferedReader in = new BufferedReader(new FileReader("read.txt"));
BufferedWriter out = new BufferedWriter(new FileWriter("write.txt"))){
String l;
while((l=in.readLine())!=null)
out.write(l);
}
catch(IOException e){System.out.println("IOException: "+e);}
MORE I am using Netbeans 8.0.1. I have gone through some similar queries on this site and have tried placing the above mentioned read.txt along with the src folder, inside it as well as along with the class file. But I am still getting this error. Can someone please point out my mistake?
I have just noticed this when trying to build project. I am new so could not understand if it has something to do with my problem
ant -f "E:\\Programming\\Projects\\java files\\JavaNio1_3" -Dnb.internal.action.name=rebuild clean jar
init:
deps-clean:
Updating property file: E:\Programming\Projects\java files\JavaNio1_3\build\built-clean.properties
Deleting directory E:\Programming\Projects\java files\JavaNio1_3\build
clean:
init:
deps-jar:
Created dir: E:\Programming\Projects\java files\JavaNio1_3\build
Updating property file: E:\Programming\Projects\java files\JavaNio1_3\build\built-jar.properties
Created dir: E:\Programming\Projects\java files\JavaNio1_3\build\classes
Created dir: E:\Programming\Projects\java files\JavaNio1_3\build\empty
Created dir: E:\Programming\Projects\java files\JavaNio1_3\build\generated-sources\ap-source-output
Compiling 1 source file to E:\Programming\Projects\java files\JavaNio1_3\build\classes
Copying 2 files to E:\Programming\Projects\java files\JavaNio1_3\build\classes
compile:
Created dir: E:\Programming\Projects\java files\JavaNio1_3\dist
Copying 1 file to E:\Programming\Projects\java files\JavaNio1_3\build
Nothing to copy.
Building jar: E:\Programming\Projects\java files\JavaNio1_3\dist\JavaNio1_3.jar
To run this application from the command line without Ant, try:
java -jar "E:\Programming\Projects\java files\JavaNio1_3\dist\JavaNio1_3.jar"
jar:
BUILD SUCCESSFUL (total time: 0 seconds)
Thank you everyone for your help. Finally solved!
I tried what kakurala had mentioned in the comments above and it worked!
"create file with java and then check whether it is creating in project directory or somewhere else. – kakurala"
thanks man..and thank you all for taking the time to answer.
This thread can be closed now :)