在java中如何以二进制的形式打开文档,并依次读取字节?请给出函数!谢谢

解决方案 »

  1.   

    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));
      

  2.   

    采用java new io;
    FileChannel fc = new FileInputStream("myfile").getChannel();
    ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
    while(bb.hasRemaining())
      

  3.   

    采用内存映射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());