Examples of transferFrom()


Examples of com.taobao.gecko.service.Connection.transferFrom()

        final Connection conn = EasyMock.createMock(Connection.class);
        EasyMock.expect(conn.getRemoteSocketAddress()).andReturn(new InetSocketAddress(8181)).anyTimes();

        final int opaque = 99;
        final IoBuffer head = IoBuffer.wrap(("value " + 2 * str.length() + " " + opaque + "\r\n").getBytes());
        conn.transferFrom(head, null, this.fileMessageSet.channel(), 0, 2 * str.length());
        EasyMock.expectLastCall();
        EasyMock.replay(conn);

        subSet.write(new GetCommand("test", "boyan-test", -1, 0, 1024 * 1024, opaque), new SessionContextImpl(null,
            conn));
View Full Code Here

Examples of io.undertow.io.BufferWritableOutputStream.transferFrom()

            file = new FileInputStream(new File(TXServlet.class.getResource(TXServlet.class.getSimpleName() + ".class").toURI())).getChannel();
        } catch (URISyntaxException e) {
        }

        BufferWritableOutputStream stream = (BufferWritableOutputStream) resp.getOutputStream();
        stream.transferFrom(file);
        file.close();
    }

    @Override
    protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
View Full Code Here

Examples of io.undertow.io.Sender.transferFrom()

                        sent++;
                        try {
                            channel.position(0);
                        } catch (IOException e) {
                        }
                        sender.transferFrom(channel, this);
                    }

                    @Override
                    public void onComplete(final HttpServerExchange exchange, final Sender sender) {
                        if (sent++ == TXS) {
View Full Code Here

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

      // Create channel on the destination
      fos = new FileOutputStream(targetFile);
      dstChannel = fos.getChannel();

      // Copy file contents from source to destination
      dstChannel.transferFrom(srcChannel, 0, srcChannel.size());

    }
    catch (IOException e)
    {
      throw new XException(Constants.LOCATION_EXTERN,
View Full Code Here

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

  public static void copyFile(String source, String destination) throws Exception {
        FileChannel srcChannel = new FileInputStream(source).getChannel();
   
        FileChannel dstChannel = new FileOutputStream(destination).getChannel();
   
        dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
   
        srcChannel.close();
        dstChannel.close();
  }
 
View Full Code Here

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

        destinationFile.createNewFile();

      outputStream = new FileOutputStream(destinationFile);
      FileChannel dstChannel = outputStream.getChannel();

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

    } catch (IOException e) {
      throw new PersistenceException(e);
    } finally {
      closeCloseable(inputStream);
View Full Code Here

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

      FileChannel dstChannel = outputStream.getChannel();

      long bytesToTransfer = srcChannel.size();
      long position = 0;
      while (bytesToTransfer > 0) {
        long bytesTransferred = dstChannel.transferFrom(srcChannel, position, bytesToTransfer);
        position += bytesTransferred;
        bytesToTransfer -= bytesTransferred;
      }

    } catch (IOException e) {
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()

    server.close();
   
    QAUtil.sleep(1000);

    try {
        fc.transferFrom(clientChannel, 0, 17);
        Assert.fail("IOException expected");
    } catch (IOException expected) { }

    file.delete();
    server.close();
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
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.