+ 1
My code exit with code 1? why?
hi guys I have following code in Main class and 1 file called 1.txt why does'n work correctly? in console : Process finished with exit code 1 import java.io.FileNotFoundException; import java.io.FileReader; public class Main { public static void main(String[] args) throws FileNotFoundException { FileReader reader=new FileReader("1.txt"); } }
3 Réponses
+ 2
//try this
import java.io.*;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
try { new File("1.txt").createNewFile(); }
catch (IOException e) { System.out.println(e); }
FileReader reader=new FileReader("1.txt");
}
}
+ 2
zemiak Martin Taylor
thank you guys😊
+ 1
Martin Taylor
I don't know what problem is
both text file and class file are in the same folder
when I put the following code in the try block it solve.
FileReader reader= new File Reader("1.txt")