Package java.nio.channels

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


            channel.write(buffer);
            assert buffer.remaining() == 0;

            while (start < endPosition)
            {
                long bytesTransferred = fc.transferTo(start, CHUNK_SIZE, channel);
                if (logger.isDebugEnabled())
                    logger.debug("Bytes transferred " + bytesTransferred);
                start += bytesTransferred;
                StreamOutManager.get(to).update(file, start);
            }
View Full Code Here


            long l = file.length();
            int fileLength = 0;
            synchronized (fc) {
                while (fileLength != l) {
                    fileLength += fc.transferTo(fileLength, l, target);
                    if (fileLength != l) {
                        logger.info("Waiting for writing...");
                        try {
                            fc.wait(1000);
                        } catch (InterruptedException e) {
View Full Code Here

                int safe_max = (64 * 1024 * 1024) / 4;
                long size = srcChannel.size();
                long position = 0;
                while (position < size)
                {
                    position += srcChannel.transferTo(position, safe_max,
                            dstChannel);
                }
            }

            // Close the channels
View Full Code Here

    public final void loadReport(final URI reportURI, final OutputStream out) throws IOException {
        Closer closer = Closer.create();
        try {
            FileInputStream in = closer.register(new FileInputStream(reportURI.getPath()));
            FileChannel channel = closer.register(in.getChannel());
            channel.transferTo(0, Long.MAX_VALUE, Channels.newChannel(out));
        } finally {
            closer.close();
        }
    }
}
View Full Code Here

                long bytesTransferred = 0;
                while (bytesTransferred < length)
                {
                    int toTransfer = (int) Math.min(CHUNK_SIZE, length - bytesTransferred);
                    limiter.acquire(toTransfer);
                    long lastWrite = fc.transferTo(section.left + bytesTransferred, toTransfer, channel);
                    bytesTransferred += lastWrite;
                    progress += lastWrite;
                    session.progress(sstable.descriptor, ProgressInfo.Direction.OUT, progress, totalSize);
                }
            }
View Full Code Here

                long bytesTransferred = 0;
                while (bytesTransferred < length)
                {
                    int toTransfer = (int) Math.min(CHUNK_SIZE, length - bytesTransferred);
                    limiter.acquire(toTransfer);
                    long lastWrite = fc.transferTo(section.left + bytesTransferred, toTransfer, channel);
                    bytesTransferred += lastWrite;
                    progress += lastWrite;
                    session.progress(sstable.descriptor, ProgressInfo.Direction.OUT, progress, totalSize);
                }
            }
View Full Code Here

                {
                    int toTransfer = (int) Math.min(CHUNK_SIZE, length - bytesTransferred);
                    long lastWrite;
                    if (sc != null)
                    {
                        lastWrite = fc.transferTo(section.left + bytesTransferred, toTransfer, sc);
                        throttle.throttleDelta(lastWrite);
                    }
                    else
                    {
                        // NIO is not available. Fall back to normal streaming.
View Full Code Here

                        condition_.await();
                    }
                }
               
                /* returns the number of bytes transferred from file to the socket */
                long bytesTransferred = fc.transferTo(startPosition, limit, socketChannel_);
                logger_.debug("Bytes transferred " + bytesTransferred);               
                bytesWritten += bytesTransferred;
                startPosition += bytesTransferred;
                /*
                 * If the number of bytes transferred is less than intended
View Full Code Here

                long bytesTransferred = 0;
                while (bytesTransferred < length)
                {
                    int toTransfer = (int) Math.min(CHUNK_SIZE, length - bytesTransferred);
                    limiter.acquire(toTransfer);
                    long lastWrite = fc.transferTo(section.left + bytesTransferred, toTransfer, channel);
                    bytesTransferred += lastWrite;
                    progress += lastWrite;
                    session.progress(sstable.descriptor, ProgressInfo.Direction.OUT, progress, totalSize);
                }
            }
View Full Code Here

                long length = section.right - section.left;
                long bytesTransferred = 0;
                while (bytesTransferred < length)
                {
                    long toTransfer = Math.min(CHUNK_SIZE, length - bytesTransferred);
                    long lastWrite = fc.transferTo(section.left + bytesTransferred, toTransfer, channel);
                    bytesTransferred += lastWrite;
                    header.file.progress += lastWrite;
                }
                if (logger.isDebugEnabled())
                    logger.debug("Bytes transferred " + bytesTransferred + "/" + header.file.size);
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.