import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; public class Test { public static void main(String[] args) throws Exception{
FileInputStream fis = new FileInputStream(new File("e:/abc.txt")); BufferedInputStream bis = new BufferedInputStream(fis); String date = "";
byte[] buff = new byte[1024]; int length = 0; StringBuilder sb = new StringBuilder(); while(-1 != (length = bis.read(buff))){ sb.append(new String(buff,0,length)); } date = sb.toString(); System.out.println(date); } }
RandomAcessFile raf = new RandomAccessFile(fileName, "r");
String data = raf.readLine();
raf.close();
* 读取文件
* @param path 文件路径
* @return 数据数组
*/
这不有注释么
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
public class Test { public static void main(String[] args) throws Exception{
FileInputStream fis = new FileInputStream(new File("e:/abc.txt"));
BufferedInputStream bis = new BufferedInputStream(fis);
String date = "";
byte[] buff = new byte[1024];
int length = 0;
StringBuilder sb = new StringBuilder();
while(-1 != (length = bis.read(buff))){
sb.append(new String(buff,0,length));
}
date = sb.toString();
System.out.println(date);
}
}