What is the simplest way to write a text file in Java?

前端 未结 9 1274
情歌与酒
情歌与酒 2021-01-01 09:55

I am wondering what is the easiest (and simplest) way to write a text file in Java. Please be simple, because I am a beginner :D

I searched the web and found this co

9条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 10:29

    You can use FileUtils from Apache Commons:

    import org.apache.commons.io.FileUtils;
    
    final File file = new File("test.txt");
    FileUtils.writeStringToFile(file, "your content", StandardCharsets.UTF_8);
    

提交回复
热议问题