Package java.nio.channels

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


            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


                        // Create channel on the destination
                        FileChannel dstChannel = new FileOutputStream(newCompleteJarName).getChannel();

                        // Copy file contents from source to destination
                        dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
                        Debug.log("Created jar file : " + newJarName + " in WASCE or Geronimo repository", module);

                        // Close the channels
                        srcChannel.close();
                        dstChannel.close();
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

            sourceChannel = sourceStream.getChannel();

            destinationStream = new FileOutputStream(newFile);
            destinationChannel = destinationStream.getChannel();

            destinationChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
            File directory = historyFile.getParentFile();
            boolean deleted = historyFile.delete();
            if (!deleted) {
                throw new WorkflowException("The old history file could not be deleted!");
            }
View Full Code Here

    }

    FileChannel srcChannel = new FileInputStream(src).getChannel();
    FileChannel dstChannel = new FileOutputStream(dest).getChannel();

    dstChannel.transferFrom(srcChannel, 0, srcChannel.size());

    srcChannel.close();
    dstChannel.close();
  }
View Full Code Here

                fail();
            } catch (UnsupportedOperationException e) {
                // expected
            }
            try {
                channel.transferFrom(channel, 0, 0);
                fail();
            } catch (UnsupportedOperationException e) {
                // expected
            }
            try {
View Full Code Here

            System.out.println("Creating war " + outputName + " ...");
            System.out.flush();
            // Now copy the new war to its destination
            srcChannel = new FileInputStream(tempFile).getChannel();
            dstChannel = new FileOutputStream(outputName).getChannel();
            dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
            srcChannel.close();
            srcChannel = null;
            dstChannel.close();
            dstChannel = null;
            tempFile.delete();
View Full Code Here

            {
                File toFile = new File(dstDir, child.getName());
                toFile.createNewFile();
                FileChannel srcChannel = new FileInputStream(child).getChannel();
                FileChannel dstChannel = new FileOutputStream(toFile).getChannel();
                dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
                srcChannel.close();
                dstChannel.close();
            }
            else
            {
View Full Code Here

            long position = 0;
            long count = srcChannel.size();
            while (position < count) {
                long chunk = Math.min(MAX_IO_CHUNK_SIZE, count - position);
                position +=
                    destChannel.transferFrom(srcChannel, position, chunk);
            }
        } finally {
            FileUtils.close(srcChannel);
            FileUtils.close(destChannel);
            FileUtils.close(out);
View Full Code Here

            {
                fis = new FileInputStream(sourceFile);
                fos = new FileOutputStream(destinationFile);
                FileChannel srcChannel = fis.getChannel();
                FileChannel dstChannel = fos.getChannel();
                dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
                srcChannel.close();
                dstChannel.close();
                success = sourceFile.delete();
            }
            catch (IOException ioex)
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.