package test;
// IO 流读取、写入文件
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class TestFile {
public static void main(String[] args) throws Exception {
String path = "src\\test.docx";
writeContent(path);
System.out.println(readFromFile(path));
}
public static void writeContent(String path) throws IOException {
for (int i = 0; i < 100; i++) {
writeToFile(path, "hello world! ( " + i + " )\n");
}
writeToFile(path, " ");
}
/**
* DOC 从文件里读取数据.
*
* @throws FileNotFoundException
* @throws IOException
*/
private static String readFromFile(String path)
throws FileNotFoundException, IOException {
Bu
IO流读取、写入文件
最新推荐文章于 2022-02-10 17:36:57 发布
![](https://img-home.csdnimg.cn/images/20240709112858.png)