标签:new 文件 读取 style code while 换行 fileinput log
1.用字节读取一个文件,替换换行符,并打印
String fileName = "src/learnIO/Stream.java"; FileInputStream in = new FileInputStream(fileName); byte[] bbuf = new byte[1024]; StringBuffer sb = new StringBuffer(in.available());
int hasRead = 0; while( (hasRead = in.read(bbuf)) > 0){ sb.append(new String(bbuf,0,hasRead)); } String content = sb.toString(); content=content.replaceAll("\r\n", "<br>"); System.out.println("12"+content);
标签:new 文件 读取 style code while 换行 fileinput log
原文地址:http://www.cnblogs.com/lakeslove/p/6002983.html