Examples of transferTo()


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

      File bakFile = new File(javaFile.getAbsolutePath() + ".bak");
      FileOutputStream fos = new FileOutputStream(bakFile);
      fos.write(DEFAULT_HEADER.getBytes());
      FileChannel fc = raf.getChannel();
      long count = raf.length() - endOfHeader;
      fc.transferTo(endOfHeader, count, fos.getChannel());
      fc.close();
      fos.close();
      raf.close();
      if (!javaFile.delete())
         log.severe("Failed to delete java file: " + javaFile);
View Full Code Here

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

            targetFileChannel = exchange.getConnection().getWorker().getXnio().openFile(tempTarget, FileAccess.READ_WRITE);
            sourceFileChannel = exchange.getConnection().getWorker().getXnio().openFile(file, FileAccess.READ_ONLY);

            StreamSinkConduit conduit = encoding.getEncoding().getResponseWrapper().wrap(new ImmediateConduitFactory<StreamSinkConduit>(new FileConduitTarget(targetFileChannel, exchange)), exchange);
            final ConduitStreamSinkChannel targetChannel = new ConduitStreamSinkChannel(null, conduit);
            long transferred = sourceFileChannel.transferTo(0, resource.getContentLength(), targetChannel);
            targetChannel.shutdownWrites();
            org.xnio.channels.Channels.flushBlocking(targetChannel);
            if (transferred != resource.getContentLength()) {
                UndertowLogger.REQUEST_LOGGER.error("Failed to write pre-cached file");
            }
View Full Code Here

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

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

               
                long bytesTransferred;
                try
                {
                    /* returns the number of bytes transferred from file to the socket */
                    bytesTransferred = fc.transferTo(startPosition, limit, socketChannel_);
                }
                catch (IOException e)
                {
                    // at least jdk1.6.0 on Linux seems to throw IOException
                    // when the socket is full. (Bug fixed for 1.7: http://bugs.sun.com/view_bug.do?bug_id=5103988)
View Full Code Here

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

     */
    private static void copyFile(File in, File out) throws IOException {
        try (FileInputStream inStream = new FileInputStream(in);
                FileOutputStream outStream = new FileOutputStream(out);) {
            FileChannel inChannel = inStream.getChannel();
            inChannel.transferTo(0, inChannel.size(), outStream.getChannel());
        }
    }

}
View Full Code Here

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

               
                long bytesTransferred;
                try
                {
                    /* returns the number of bytes transferred from file to the socket */
                    bytesTransferred = fc.transferTo(startPosition, limit, socketChannel_);
                }
                catch (IOException e)
                {
                    // at least jdk1.6.0 on Linux seems to throw IOException
                    // when the socket is full. (Bug fixed for 1.7: http://bugs.sun.com/view_bug.do?bug_id=5103988)
View Full Code Here

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

            targetFileChannel = exchange.getConnection().getWorker().getXnio().openFile(tempTarget, FileAccess.READ_WRITE);
            sourceFileChannel = exchange.getConnection().getWorker().getXnio().openFile(file, FileAccess.READ_ONLY);

            StreamSinkConduit conduit = encoding.getEncoding().getResponseWrapper().wrap(new ImmediateConduitFactory<StreamSinkConduit>(new FileConduitTarget(targetFileChannel, exchange)), exchange);
            final ConduitStreamSinkChannel targetChannel = new ConduitStreamSinkChannel(null, conduit);
            long transferred = sourceFileChannel.transferTo(0, resource.getContentLength(), targetChannel);
            targetChannel.shutdownWrites();
            org.xnio.channels.Channels.flushBlocking(targetChannel);
            if (transferred != resource.getContentLength()) {
                UndertowLogger.REQUEST_LOGGER.error("Failed to write pre-cached file");
            }
View Full Code Here

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

                    socketChannel_.write(buffer);
                    handleIncompleteWrite(buffer);
                }
               
                /* 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

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

               
                long bytesTransferred;
                try
                {
                    /* returns the number of bytes transferred from file to the socket */
                    bytesTransferred = fc.transferTo(startPosition, limit, socketChannel_);
                }
                catch (IOException e)
                {
                    // at least jdk1.6.0 on Linux seems to throw IOException
                    // when the socket is full. (Bug fixed for 1.7: http://bugs.sun.com/view_bug.do?bug_id=5103988)
View Full Code Here

Examples of krati.core.segment.Segment.transferTo()

                        succ = false;
                        break;
                    }
                   
                    // Transfer bytes from source to target
                    segSource.transferTo(oldSegPos, byteCnt, segTarget);
                    bytesTransferred += byteCnt;
                   
                    if(sibTarget != null) sibTarget.add(index, (int)newSegPos);
                    _updateManager.addUpdate(index, byteCnt, newAddress, oldAddress, segTarget);
                }
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.