Package java.nio.channels

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


    String file = getName(path);
    FileOutputStream outStream = new FileOutputStream(dir.getPath() + File.separator + file);

    ReadableByteChannel in = Channels.newChannel(entry.openStream());
    FileChannel out = outStream.getChannel();
    out.transferFrom(in, 0, Integer.MAX_VALUE);

    in.close();
    out.close();
  }
View Full Code Here


       
        FileChannel readableChannel = fis.getChannel();
        FileChannel writableChannel = fos.getChannel();
       
        writableChannel.truncate(0);
        writableChannel.transferFrom(readableChannel, 0, readableChannel.size());
        fis.close();
        fos.close();
        return true;
      }
      catch (IOException ioe) {
View Full Code Here

      FileChannel readableChannel = inputStream.getChannel();
      FileChannel writableChannel = outputStream.getChannel();

      writableChannel.truncate(0);
      writableChannel.transferFrom(
        readableChannel, 0, readableChannel.size());
      inputStream.close();
      outputStream.close();
    } catch (IOException ioException) {
      String exceptionMessage =
View Full Code Here

      FileChannel readableChannel = inputStream.getChannel();
      FileChannel writableChannel = outputStream.getChannel();

      writableChannel.truncate(0);
      writableChannel.transferFrom(
        readableChannel, 0, readableChannel.size());
      inputStream.close();
      outputStream.close();
    } catch (IOException ioException) {
      String exceptionMessage =
View Full Code Here

       
        fchannel.position (0);
       
        FileChannel fc2 = new FileOutputStream (bfile).getChannel ();
       
        fc2.transferFrom (fchannel, 0, fchannel.size ());
       
        fc2.close ();
      
        if (this.useFileChannelSync == false) {
           
View Full Code Here

            long pos = 0;
            long count = 0;
            while (pos < size) {
                final long remain = size - pos;
                count = remain > FILE_COPY_BUFFER_SIZE ? FILE_COPY_BUFFER_SIZE : remain;
                final long bytesCopied = output.transferFrom(input, pos, count);
                if (bytesCopied == 0) { // IO-385 - can happen if file is truncated after caching the size
                    break; // ensure we don't loop forever
                }
                pos += bytesCopied;
            }
View Full Code Here

    FileChannel source = null;
    FileChannel destination = null;
    try {
      source = new FileInputStream(sourceFile).getChannel();
      destination = new FileOutputStream(destFile).getChannel();
      destination.transferFrom(source, 0, source.size());
    }
    catch (IOException e) {
      e.printStackTrace();
    }
    finally {
View Full Code Here

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

        try {
            @SuppressWarnings("resource")
            FileChannel sourceChannel = new FileInputStream(source).getChannel();
            @SuppressWarnings("resource")
            FileChannel destChannel = new FileOutputStream(dest).getChannel();
            destChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
            sourceChannel.close();
            destChannel.close();
        } catch (IOException ex) { IO.exception(ex); }
    }
View Full Code Here

            output = fos.getChannel();

            long size = input.size();
            long pos = 0;
            while (pos < size) {
                pos += output.transferFrom(input, pos, Math.min(size - pos, bufferSize));
            }
        }
        finally {
            closeQuietly(fos);
            closeQuietly(fis);
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.