Package java.nio.channels

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


            try
            {
                FileChannel target = ((FileOutputStream) output).getChannel();
                FileChannel source = ((FileInputStream) input).getChannel();
               
                source.transferTo(0, Integer.MAX_VALUE, target);
               
                source.close();
                target.close();
               
                return;
View Full Code Here


        long count = 0;
        long n = 0;
        if (input instanceof FileInputStream) {
            FileChannel inChannel = ((FileInputStream) input).getChannel();
            WritableByteChannel outChannel = Channels.newChannel(output);
            count = inChannel.transferTo(offset, inChannel.size() - offset, outChannel);
        } else if (output instanceof FileOutputStream) {
            FileChannel outChannel = ((FileOutputStream) output).getChannel();
            ReadableByteChannel inChannel = Channels.newChannel(input);
            do {
                n = outChannel.transferFrom(inChannel, offset + count, DEFAULT_BUFFER_SIZE);
View Full Code Here

        long rcount = 0;
        long n = 0;
        if (input instanceof FileInputStream) {
            FileChannel inChannel = ((FileInputStream) input).getChannel();
            WritableByteChannel outChannel = Channels.newChannel(output);
            rcount = inChannel.transferTo(offset, count, outChannel);
        } else if (output instanceof FileOutputStream) {
            FileChannel outChannel = ((FileOutputStream) output).getChannel();
            ReadableByteChannel inChannel = Channels.newChannel(input);
            do {
                if (count < DEFAULT_BUFFER_SIZE) {
View Full Code Here

        long count = 0;
        long n = 0;
        if (input instanceof FileInputStream) {
            FileChannel inChannel = ((FileInputStream) input).getChannel();
            WritableByteChannel outChannel = Channels.newChannel(output);
            count = inChannel.transferTo(0, inChannel.size(), outChannel);
        } else if (output instanceof FileOutputStream) {
            FileChannel outChannel = ((FileOutputStream) output).getChannel();
            ReadableByteChannel inChannel = Channels.newChannel(input);
            do {
                n = outChannel.transferFrom(inChannel, count, DEFAULT_BUFFER_SIZE);
View Full Code Here

    for(String file:files){
      File f = new File(file);
      if(!f.exists())
        continue;
      inFileChannel=new FileInputStream(f).getChannel();
      inFileChannel.transferTo(0, inFileChannel.size(), mFileChannel);

      inFileChannel.close();
    }

    mFileChannel.close();
View Full Code Here

    FileChannel inFileChannel;
    for(File file:files){
      if(!file.exists())
        continue;
      inFileChannel=new FileInputStream(file).getChannel();
      inFileChannel.transferTo(0, inFileChannel.size(), mFileChannel);

      inFileChannel.close();
    }

    mFileChannel.close();
View Full Code Here

                long length = section.right - section.left;
                long bytesTransferred = 0;
                while (bytesTransferred < length)
                {
                    long toTransfer = Math.min(CHUNK_SIZE, length - bytesTransferred);
                    long lastWrite = fc.transferTo(section.left + bytesTransferred, toTransfer, channel);
                    bytesTransferred += lastWrite;
                    header.file.progress += lastWrite;
                }
                if (logger.isDebugEnabled())
                    logger.debug("Bytes transferred " + bytesTransferred + "/" + header.file.size);
View Full Code Here

                if ( toFile.exists() ) {
                    try {
                        RandomAccessFile file = new RandomAccessFile(toFile, "rw");
                        file.seek( file.length() );
                        FileChannel logChannel = new FileInputStream(log).getChannel();
                        logChannel.transferTo(0, logChannel.size(), file.getChannel());
                        file.close();
                        logChannel.close();
                        log.delete();  
                    }
                    catch (IOException e) {
View Full Code Here

        FileChannel out = null;
        try {
            FileChannel in = new FileInputStream(source).getChannel();
            File outFile = new File(destination);
            out = new FileOutputStream(outFile).getChannel();
            in.transferTo(0, in.size(), out);
        } finally {
            if (out != null) {
                out.close();
            }
        }
View Full Code Here

                out = Channels.newChannel(os);
            }
            FileChannel fc = s.getChannel();
            long pos = 0;
            while (pos < len) {
                long i = fc.transferTo(pos, len - pos, out);
                pos += i;
            }
            s.close();
            fc.close();
        } else {
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.