import java.io.FileReader;
import java.io.IOException;
/**
* 从磁盘读取一个文件到内存中,再打印到控制台
*/
class IO4 {
public static void main(String[] args) {
FileReader fr = null;
try {
fr = new FileReader("I://bb.txt");
char[] buf = new char[1024];
int len = 0;
while ((len = fr.read(buf)) != -1) {
System.out.println(new String(buf, 0, len));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fr != null)
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
从磁盘读取一个文件到内存中,再打印到控制台
最新推荐文章于 2023-03-22 20:48:41 发布