BufferedReader in=new BufferedReader(
new FileReader(
"G:\\temp-workspace\\DONE\\src\\cn\\sccl\\common\\SystemConfiguration.java"));
String s,s2=new String();
while((s=in.readLine())!=null) s2+=s+"\n";
System.out.println(s2);
in.close();
//从格式化内存读入
try{
DataInputStream in3=new DataInputStream(
new ByteArrayInputStream(s2.getBytes()));
while(true)
System.out.print((char)in3.readByte()+"\n");
}catch(EOFException e){
System.err.println("End of stream");
}c
本文介绍了一种使用Java进行文件读取的方法,通过BufferedReader和DataInputStream类实现了从文件中逐行读取内容并进行格式化处理的过程。示例代码展示了如何将文件内容拼接成字符串,并进一步通过字节流进行字符输出。

被折叠的 条评论
为什么被折叠?



