Я создал новый проект в IntelliJ и создал новый класс со следующим кодом:
import java.io.PrintWriter;
public class myWriter {
public static void main(String[] arg){
PrintWriter writeMe = new PrintWriter("newFIle.txt");
writeMe.println("Just writing some text to print to your file ");
writeMe.close();
}
}
Я ожидаю, что это создаст txtfile в рабочем каталоге, содержащем «Просто записать текст для печати в ваш файл». Тем не менее, он просто вернул ошибку:
Error:(5, 31) java: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown