Package java.nio.channels

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


      fail();
    } catch (ClosedChannelException expected) {
    }

    try {
      channel.transferTo(0, 10, new ByteBufferChannel(buffer("111")));
      fail();
    } catch (ClosedChannelException expected) {
    }

    executor.shutdown();
View Full Code Here


      fail();
    } catch (NonReadableChannelException expected) {
    }

    try {
      channel.transferTo(0, 10, new ByteBufferChannel(buffer("111")));
      fail();
    } catch (NonReadableChannelException expected) {
    }

    try {
View Full Code Here

  @Test
  public void testTransferToNegative() throws IOException {
    FileChannel channel = channel(regularFile(0), READ, WRITE);

    try {
      channel.transferTo(-1, 0, new ByteBufferChannel(10));
      fail();
    } catch (IllegalArgumentException expected) {
    }

    try {
View Full Code Here

      fail();
    } catch (IllegalArgumentException expected) {
    }

    try {
      channel.transferTo(0, -1, new ByteBufferChannel(10));
      fail();
    } catch (IllegalArgumentException expected) {
    }
  }
View Full Code Here

        try {
            sourceStream = new FileInputStream( file );
            FileChannel sourceChannel = sourceStream.getChannel();

            WritableByteChannel targetChannel = Channels.newChannel( targetStream );
            sourceChannel.transferTo( 0, sourceChannel.size(), targetChannel );

            sourceStream.close();
            file.delete();
        }
        catch( FileNotFoundException ex ) {
View Full Code Here

            throw new IllegalArgumentException("Cannot load from file more than 2GB: " + file);
        LBuffer b = new LBuffer((int) fileSize);
        long pos = 0L;
        WritableChannelWrap ch = new WritableChannelWrap(b);
        while (pos < fileSize) {
            pos += fin.transferTo(0, fileSize, ch);
        }
        return b;
    }

View Full Code Here

    FileChannel inputChannel = null;
    WritableByteChannel outputChannel = null;
    try {
      inputChannel = inputStream.getChannel();
      outputChannel = Channels.newChannel(outputStream);
      inputChannel.transferTo(0, inputChannel.size(), outputChannel);
      outputStream.finish();
    } catch (ClosedByInterruptException e) {
      // may occur if we're closing down
      LogLog.debug("Compression operation interrupted");
      return false;
View Full Code Here

    FileChannel inputChannel = null;
    try {
      inputChannel = inputStream.getChannel();
      final WritableByteChannel outputChannel = Channels
          .newChannel(outputStream);
      inputChannel.transferTo(0, inputChannel.size(), outputChannel);
      // Original implementation
      // while (inputStream.available() > 0) {
      // int data = inputStream.read();
      // if (data == -1) {
      // break;
View Full Code Here

        String messageFileName = getMessageFileName(emailID);
        String indexErrorFileName = getIndexErrorFileName(emailID);
        try {         
             in = new FileInputStream(messageFileName).getChannel();
             out = new FileOutputStream(indexErrorFileName).getChannel();
             in.transferTo( 0, in.size(), out);
           
        } catch (Exception e) {
            throw new MessageStoreException("failed to copy suspect message to noindex queue {src='"+messageFileName+"=',dest='"+indexErrorFileName+"'",logger);
        } finally {
             if (in != null) try { in.close(); } catch (Exception e) {};
View Full Code Here

        String messageFileName = getMessageFileName(emailID);
        String indexErrorFileName = getIndexErrorFileName(emailID);
        try {         
             in = new FileInputStream(messageFileName).getChannel();
             out = new FileOutputStream(indexErrorFileName).getChannel();
             in.transferTo( 0, in.size(), out);
           
        } catch (Exception e) {
            throw new MessageStoreException("failed to copy suspect message to noindex queue {src='"+messageFileName+"=',dest='"+indexErrorFileName+"'",logger);
        } finally {
             if (in != null) try { in.close(); } catch (Exception e) {};
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.