日期:2014-05-20 浏览次数:20727 次
String fileName = "e:\\abc.tx"; RandomAcessFile raf = new RandomAccessFile(fileName, "r"); String data = raf.readLine(); raf.close();
------解决方案--------------------
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); } }