高效文件操作

来源:互联网 发布:人工智能机器人有哪些 编辑:程序博客网 时间:2024/05/22 15:06

       

       FileChannel  ifc=new RandomAccessFile(file, "rw").getChannel();
       FileChannel  ofc = new RandomAccessFile(file, "rw").getChannel();
       MappedByteBuffer imb=ifc.map(FileChannel.MapMode.READ_ONLY, 0, 10);
       MappedByteBuffer omb=ifc.map(FileChannel.MapMode.READ_WRITE, 0, 10);
       for(int i=0;i<10;i++){
        byte ib=imb.get(i);
        ib= (byte) (ib^0X11);
        omb.put(i,ib);
       }
        ifc.close();
        ofc.close();

原创粉丝点击