I created a new project in IntelliJ and created a new class with the following code:
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();
}
}
I expect this to create a txtfile in the working directory containing "Just writing some text to print to your file ". However, it just returned the error:
Error:(5, 31) java: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown