My code is very simple and straight forward. I create an empty file using the PrintWriter
class and write the numbers 1 - 100 to the file, then close the file. As far as I know, PrintWriter
should create the empty file, which makes me wonder why I'm getting this FileNotFoundException
error.
public class Practice {
public static void main(String[] args){
PrintWriter outputFile = new PrintWriter("nums.txt");
for(int i = 0; i < 100; i++)
outputFile.println(i + 1);
out.close();
}
}