使用Java文件流将“E:\\kj.txt”文件中的内容读取并输出到控制台。

如题所述

把文件位置替换成你的就可以了

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class HelloWorld {

public static void main(String[] args) throws IOException {
FileInputStream fs = new FileInputStream("E:\\22.txt");
byte[] buf = new byte[1024*20];
int k = fs.read(buf, 0, buf.length);
System.out.println(new String(buf))
}

}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答