Package java.nio.channels

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


               {
                  chf = File.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


         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

                  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
                  // TODO don't use Channels.newChannel in Java5
View Full Code Here

                  }

                  // write update data
                  // TODO don't use Channels.newChannel in Java5
                  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

                  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

               {
                  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

   
            // Create channel on the destination
            dstChannel = fileOutputStream.getChannel();
   
            // Copy file contents from source to destination
            dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
        } finally {
            // Close the channels
            try{
                if( fileInputStream!=null )
                    fileInputStream.close();
View Full Code Here

         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

    FileChannel destination = null;
    try
      {
        source = new FileInputStream(src).getChannel();
        destination = new FileOutputStream(dst).getChannel();
        destination.transferFrom(source, 0, source.size());
      }
    finally
      {
        if (source != null)
          source.close();
View Full Code Here

        File outFile = File.createTempFile(getName(path)+"-", ".tmp", dir);
        FileOutputStream outStream = new FileOutputStream(outFile);
       
        ReadableByteChannel in = Channels.newChannel(entry.openStream());
        FileChannel out = outStream.getChannel();
        out.transferFrom(in, 0, Integer.MAX_VALUE);
       
        in.close();
        out.close();

        return outFile;
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.