| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
openocode
10年前发布

使用org.apache.commons.io.FileUtils写文件

import java.io.File;  import java.io.IOException;  import org.apache.commons.io.FileUtils;    public class SetContent {      public static void main(String[] args) {          try {                // We take a reference to an actual file on disk              File file = new File("test.txt");                // We set the string to be written to the file              String data = "Hi,test!!!";                // We write to the file with writeStringToFile Method              FileUtils.writeStringToFile(file, data);                // We test the result              String content = FileUtils.readFileToString(file);                 System.out.println("Content : " + content);            } catch (IOException e) {              e.printStackTrace();          }        }  }