Examples of transferFrom()


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

            outFile = new File(toDirectory, file.getName());
            fos = new FileOutputStream(outFile);
            FileChannel outCh = fos.getChannel();

            outCh.transferFrom(inCh, 0, inCh.size());

            return outFile;
        } catch (IOException ioe) {
            LOG.error(ioe);
            throw ioe;
View Full Code Here

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

                  ReadableByteChannel bch = Channels.newChannel(new ByteArrayInputStream(this.data));

                  if ((newIndex = (int)position) > 0)
                  {
                     // begin from the existed bytes
                     chch.transferFrom(bch, 0, newIndex < data.length ? newIndex : data.length);
                     bch.close();
                  }

                  // write update data
                  ReadableByteChannel sch = Channels.newChannel(stream);
View Full Code Here

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

                     bch.close();
                  }

                  // write update data
                  ReadableByteChannel sch = Channels.newChannel(stream);
                  chch.transferFrom(sch, newIndex, length);
                  sch.close();
                  newIndex += length;

                  if (newIndex < data.length)
                     // write the rest of existed data
View Full Code Here

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

                  sch.close();
                  newIndex += length;

                  if (newIndex < data.length)
                     // write the rest of existed data
                     chch.transferFrom(bch, newIndex, data.length - newIndex);

                  bch.close();
               }
               catch (final IOException e)
               {
View Full Code Here

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

               {
                  chf = SpoolFile.createTempFile("jcrvdedit", null, tempDirectory);
                  chch = new RandomAccessFile(chf, "rw").getChannel();

                  ReadableByteChannel bch = Channels.newChannel(new ByteArrayInputStream(this.data));
                  chch.transferFrom(bch, 0, this.data.length); // get all
                  bch.close();

                  if (chch.size() < size)
                  {
                     // extend length
View Full Code Here

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

         long size = 0;
         long r = 0;
         do
         {
            r = outfch.transferFrom(infch, r, infch.size());
            size += r;
         }
         while (r < infch.size());
         return size;
      }
View Full Code Here

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

        FileChannel destination = null;

        try {
            source = new FileInputStream(sourceFile).getChannel();
            destination = new FileOutputStream(destFile).getChannel();
            destination.transferFrom(source, 0, source.size());
        } catch (IOException ioe) {
            throw new RuntimeException("Unable to copy " + sourceFile.getAbsolutePath() + " to " + destFile.getAbsolutePath(), ioe);
        } finally {
            if(source != null) {
                try {
View Full Code Here

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

      FileChannel oChannel = os.getChannel();
      long doneBytes = 0L;
      long todoBytes = srcFile.length();
      while ( todoBytes != 0L ) {
        long iterationBytes = Math.min( todoBytes, chunkSize );
        long transferredLength = oChannel.transferFrom( iChannel, doneBytes, iterationBytes );
        if ( iterationBytes != transferredLength ) {
          throw new IOException( "Error during file transfer: expected "
              + iterationBytes + " bytes, only "+ transferredLength + " bytes copied." );
        }
        doneBytes += transferredLength;
View Full Code Here

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

            long pos = 0;
            long count = 0;
            while ( pos < size )
            {
                count = size - pos > FILE_COPY_BUFFER_SIZE ? FILE_COPY_BUFFER_SIZE : size - pos;
                pos += output.transferFrom( input, pos, count );
            }
        }
        finally
        {
            IOUtil.close( output );
View Full Code Here

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

            + " dst : " + dst);
      }
      long bytesLeft = input.size();
      long position = 0;
      while (bytesLeft > 0) {
        long bytesWritten = output.transferFrom(input, position, bytesLeft);
        bytesLeft -= bytesWritten;
        position += bytesWritten;
      }
      if (datanode.syncOnClose) {
        output.force(true);
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.