Package java.nio.channels

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


                    }
                    catch (InterruptedException ex) {
                    }
                }
                log.finest( "filechannel pos:" + fc.position()+" part: "+i+" of "+c );
                if (fc.position() < (i * PARTSIZE)) {
                    bb.limit((int) ((i * PARTSIZE) - fc.position()));
                    fc.read(bb);
                    bb.flip();
                    msgDigest.update(bb);
                    bb.rewind();
View Full Code Here


                    catch (InterruptedException ex) {
                    }
                }
                log.finest( "filechannel pos:" + fc.position()+" part: "+i+" of "+c );
                if (fc.position() < (i * PARTSIZE)) {
                    bb.limit((int) ((i * PARTSIZE) - fc.position()));
                    fc.read(bb);
                    bb.flip();
                    msgDigest.update(bb);
                    bb.rewind();
                    try {
View Full Code Here

                msgDigest.finalDigest(hashset);
                int progress = (int)Math.floor(i*100.0/c);
                propertyChangeSupport.firePropertyChange("fileIndexingInProgress", "[ED2K] " + file.getName(), new Integer(progress));
            }
            if (c > 0) {
                while (fc.position() < (fc.size())) {
                    fc.read(bb);
                    bb.flip();
                    msgDigest.update(bb);
                    bb.rewind();
                    try {
View Full Code Here

      if(dh[0] != 'M' || dh[1] != 'Z')
        throw new IOException("The native library is not an executable file.");

      // legge offset header PE e seek del file
      long offset = BitUtils.getDWordValue(dh, 60);
      ch.position(offset);

      // carica IMAGE_NT_HEADERS (primi 6 byte sono sufficienti)
      ByteBuffer pehdr = ByteBuffer.allocate(6);
      if(ch.read(pehdr) != 6)
        throw new IOException("Invalid nativelib file.");
View Full Code Here

     * eg. it should append or override any existing content.
     */
    private FileChannel prepareOutputFileChannel(File target) throws IOException {
        if (endpoint.getFileExist() == GenericFileExist.Append) {
            FileChannel out = new RandomAccessFile(target, "rw").getChannel();
            return out.position(out.size());
        }
        return new FileOutputStream(target).getChannel();
    }
}
View Full Code Here

          blockIn instanceof FileInputStream) {
       
        FileChannel fileChannel = ((FileInputStream)blockIn).getChannel();
       
        // blockInPosition also indicates sendChunks() uses transferTo.
        blockInPosition = fileChannel.position();
        streamForSendChunks = baseStream;
       
        // assure a mininum buffer size.
        maxChunksPerPacket = (Math.max(BUFFER_SIZE,
                                       MIN_BUFFER_WITH_TRANSFERTO)
View Full Code Here

            FileChannel f2 = (FileChannel)d2.getChannel();

            try {
                long size = f1.size();

                f1.transferTo(f2.position(), size, f2);

                return context.getRuntime().newFixnum(size);
            } catch (IOException ioe) {
                throw runtime.newIOErrorFromException(ioe);
            }
View Full Code Here

            try {
                long pos;
                switch (whence) {
                case Stream.SEEK_SET:
                    pos = offset;
                    fileChannel.position(pos);
                    break;
                case Stream.SEEK_CUR:
                    pos = fileChannel.position() + offset;
                    fileChannel.position(pos);
                    break;
View Full Code Here

                case Stream.SEEK_SET:
                    pos = offset;
                    fileChannel.position(pos);
                    break;
                case Stream.SEEK_CUR:
                    pos = fileChannel.position() + offset;
                    fileChannel.position(pos);
                    break;
                case Stream.SEEK_END:
                    pos = fileChannel.size() + offset;
                    fileChannel.position(pos);
View Full Code Here

                    pos = offset;
                    fileChannel.position(pos);
                    break;
                case Stream.SEEK_CUR:
                    pos = fileChannel.position() + offset;
                    fileChannel.position(pos);
                    break;
                case Stream.SEEK_END:
                    pos = fileChannel.size() + offset;
                    fileChannel.position(pos);
                    break;
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.