Package java.nio.channels

Examples of java.nio.channels.FileChannel.position()


        long remainingInFile = fc.size()-offset;
        long remainingInTargetBuffer = buffer.remaining(DirectByteBuffer.SS_FILE);
        MappedByteBuffer buf = fc.map(MapMode.READ_ONLY, offset, Math.min(remainingInFile,remainingInTargetBuffer));
        buffer.put(DirectByteBuffer.SS_FILE, buf);
      } else {
        fc.position(offset);
        while (fc.position() < fc.size() && buffer.hasRemaining(DirectByteBuffer.SS_FILE))
          buffer.read(DirectByteBuffer.SS_FILE,fc);       
      }

     
View Full Code Here


        long remainingInTargetBuffer = buffer.remaining(DirectByteBuffer.SS_FILE);
        MappedByteBuffer buf = fc.map(MapMode.READ_ONLY, offset, Math.min(remainingInFile,remainingInTargetBuffer));
        buffer.put(DirectByteBuffer.SS_FILE, buf);
      } else {
        fc.position(offset);
        while (fc.position() < fc.size() && buffer.hasRemaining(DirectByteBuffer.SS_FILE))
          buffer.read(DirectByteBuffer.SS_FILE,fc);       
      }

     
     
View Full Code Here

        }
         
       
      } else {
       
        fc.position(offset);
        ByteBuffer[]  bbs = new ByteBuffer[buffers.length];
       
        ByteBuffer  last_bb  = null;
        for (int i=0;i<bbs.length;i++){
          ByteBuffer bb = bbs[i] = buffers[i].getBuffer(DirectByteBuffer.SS_FILE);
View Full Code Here

            // bail out if we've completed the read or got to file end
            // a "better" fix would be to prevent the over-read in the first
            // place, but hey, we're just about to release and there may be other
            // instances of this...

          while ( fc.position() < fc.size() && last_bb.hasRemaining()){
            long  read = fc.read( bbs );
            if ( read > 0 ){
              loop  = 0;
            }else{
              loop++;
View Full Code Here

          original_positions[i] = buffers[i].position(DirectByteBuffer.SS_FILE);
        }
       
        if(position+size > fc.size())
        {
          fc.position(position+size-1);
          fc.write(ByteBuffer.allocate(1));
          fc.force(true);
        }
         
        MappedByteBuffer buf = fc.map(MapMode.READ_WRITE, position, size);
View Full Code Here

          for (int i=0;i<buffers.length;i++){
            expected_write += buffers[i].limit(DirectByteBuffer.SS_FILE) - buffers[i].position(DirectByteBuffer.SS_FILE);
          }
        }
       
        fc.position( position );
        ByteBuffer[]  bbs = new ByteBuffer[buffers.length];


        ByteBuffer  last_bb  = null;
        for (int i=0;i<bbs.length;i++){
View Full Code Here

  public static  Map<Int128, Index> loadFile(String fileName) throws Throwable {
    Map<Int128, Index> result = new Hashtable<Int128, Index>();
    FileChannel channel = new RandomAccessFile(fileName,"rw").getChannel();
   
    channel.position(4+4);
   
    ByteBuffer data;
   
    data = getByteBuffer(4);
   
View Full Code Here

   
    try {
      FileChannel channel = new RandomAccessFile(fileName,"rw").getChannel();
     
      ByteBuffer data = getByteBuffer(4);
      channel.position(4); // skip 'old' contacts count field
     
      channel.read(data); // nodes.dat version
     
      data.position(0);
      channel.read(data);
View Full Code Here

    ByteBuffer tagBuffer = tc.convert(tag);

    if (!tagExists(raf)) {
      //System.err.println("Creating a new ID3v1 Tag");
      fc.position(fc.size());
      fc.write(tagBuffer);
      //ID3v1 Tag Written
    } else {
      //System.err.println("Old ID3v1 Tag found, replacing the old tag");
      fc.position(fc.size() - 128);
View Full Code Here

      fc.position(fc.size());
      fc.write(tagBuffer);
      //ID3v1 Tag Written
    } else {
      //System.err.println("Old ID3v1 Tag found, replacing the old tag");
      fc.position(fc.size() - 128);
      fc.write(tagBuffer);
    }
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.