清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
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(); } } }