error: unreported exception FileNotFoundException; must be caught or declared to be thrown

后端 未结 4 1752
再見小時候
再見小時候 2020-12-06 11:12

I\'m trying to create a simple program that will output a string to a text file. Using code I found here, I have put together the following code:

import jav         


        
4条回答
  •  太阳男子
    2020-12-06 11:38

    If you're very new to Java, and just trying to learn how to use PrintWriter, here is some bare-bones code:

    import java.io.*;
    
    public class SimpleFile {
        public static void main (String[] args) throws IOException {
            PrintWriter writeMe = new PrintWriter("newFIle.txt");
            writeMe.println("Just writing some text to print to your file ");
            writeMe.close();
        }
    }
    

提交回复
热议问题