BufferedInputStream in =new BufferedInputStream(new FileInputStream("Flie_name")); byte[] buf=new byte[100]; int len=fis.read(buf); System.out.println(new String(buf,0,len));
采用java new io; FileChannel fc = new FileInputStream("myfile").getChannel(); ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); while(bb.hasRemaining())
采用内存映射io,稳定,高效; FileChannel fc = new FileInputStream("myfile").getChannel(); ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); while(bb.hasRemaining()) System.out.println(bb.get());
byte[] buf=new byte[100];
int len=fis.read(buf);
System.out.println(new String(buf,0,len));
FileChannel fc = new FileInputStream("myfile").getChannel();
ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
while(bb.hasRemaining())
FileChannel fc = new FileInputStream("myfile").getChannel();
ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
while(bb.hasRemaining())
System.out.println(bb.get());