Examples of transferFrom()


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

    QAUtil.sleep(200);
   
    clientChannel.close();
   
    try {
      fc.transferFrom(clientChannel, 0, 9000000);
      Assert.fail("ClosedChannelException expected");
    } catch (ClosedChannelException expected) { }
   
    file.delete();
    server.close();
View Full Code Here

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

    QAUtil.sleep(200);
   
    clientChannel.close();
   
    try {
      fc.transferFrom(clientChannel, 0, 9000000);
      Assert.fail("ClosedChannelException expected");
    } catch (ClosedChannelException expected) { }
   
    file.delete();
    server.close();
View Full Code Here

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

    String txt = "Hello my client\r\n";
    serverChannel.write(txt);
    serverChannel.flush();
    QAUtil.sleep(200);
   
    long transfered = fc.transferFrom(clientChannel, 0, 9000000);
    fc.close();
    raf.close();
   
    Assert.assertEquals(txt.length(), transfered);
    Assert.assertTrue(QAUtil.isEquals(file, txt));
View Full Code Here

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

          ioe.toString();
        };
      }
    };
    t.start();
    long transfered = fc.transferFrom(clientChannel, 0, 9000000);
    fc.close();
    raf.close();
    Assert.assertEquals(txt.length(), transfered);
    Assert.assertTrue(QAUtil.isEquals(file, txt));
    Assert.assertFalse(clientChannel.isOpen());
View Full Code Here

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

    serverChannel.write(txt);
    serverChannel.flush();
    serverChannel.close();
    QAUtil.sleep(200);
   
    long transfered = fc.transferFrom(clientChannel, 0, 9000000);
    fc.close();
    raf.close();
   
    Assert.assertEquals(txt.length(), transfered);
    Assert.assertTrue(QAUtil.isEquals(file, txt));
View Full Code Here

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

    QAUtil.sleep(200);
   
    clientChannel.close();
   
    try {
      fc.transferFrom(clientChannel, 0, 9000000);
      Assert.fail("ClosedChannelException expected");
    } catch (ClosedChannelException expected) { }
   
    file.delete();
    server.close();
View Full Code Here

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

    QAUtil.sleep(200);
   
    clientChannel.close();
   
    try {
      fc.transferFrom(clientChannel, 0, 9000000);
      Assert.fail("ClosedChannelException expected");
    } catch (ClosedChannelException expected) { }
   
    file.delete();
    server.close();
View Full Code Here

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

            FileChannel fromCh = in.getChannel();
            FileChannel toCh = out.getChannel();
            long size = fromCh.size();
            long toCopy = size;
            while (toCopy > 0) {
                toCopy -= toCh.transferFrom(fromCh, size - toCopy, toCopy);
            }
        } finally {
            try {
                in.close();
            } catch (IOException e) {
View Full Code Here

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

        {
            in = new FileInputStream(src);
            out = new FileOutputStream(target);
            FileChannel inCh = in.getChannel();
            FileChannel outCh = out.getChannel();
            if (outCh.transferFrom(inCh, 0, src.length()) == src.length())
            {
                // adjust timestamp
                target.setLastModified(src.lastModified());
                flag = true;
            }
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());
      }
      finally {
          if(source != null) {
              source.close();
          }
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.