Class Channels

org.elasticsearch.common.io.Channels

public final class Channels extends
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
    The maximum chunk size for writes in bytes
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
     channel, long channelPosition, byte[] dest, int destOffset, int length)
    read length bytes from position of a file channel.
    static byte[]
     channel, long position, int length)
    read length bytes from position of a file channel
    static int
     channel, long channelPosition,  dest)
    read from a file channel into a byte buffer, starting at a certain position.
    static void
     channel, long channelPosition, byte[] dest, int destOffset, int length)
    read length bytes from position of a file channel.
    static int
     channel, long channelPosition,  dest)
    read from a file channel into a byte buffer, starting at a certain position.
    static void
    writeToChannel​(byte[] source, int offset, int length,  channel, long channelPosition)
    Writes part of a byte array to a at the provided position.
    static void
    writeToChannel​(byte[] source, int offset, int length,  channel)
    Writes part of a byte array to a
    static void
    writeToChannel​(byte[] source,  channel, long channelPosition)
    Writes part of a byte array to a at the provided position.
    static void
    writeToChannel​(byte[] source,  channel)
    Writes part of a byte array to a
    static void
     byteBuffer,  channel)
    Writes a to a

    Methods inherited from class java.lang.

    , , , , , , , , , ,
  • Field Details

    • WRITE_CHUNK_SIZE

      public static final int WRITE_CHUNK_SIZE
      The maximum chunk size for writes in bytes
      See Also:
      Constant Field Values
  • Method Details

    • readFromFileChannel

      public static byte[] readFromFileChannel( channel, long position, int length) throws
      read length bytes from position of a file channel
      Throws:
    • readFromFileChannelWithEofException

      public static void readFromFileChannelWithEofException( channel, long channelPosition, byte[] dest, int destOffset, int length) throws
      read length bytes from position of a file channel. An EOFException will be thrown if you attempt to read beyond the end of file.
      Parameters:
      channel - channel to read from
      channelPosition - position to read from
      dest - destination byte array to put data in
      destOffset - offset in dest to read into
      length - number of bytes to read
      Throws:
    • readFromFileChannel

      public static int readFromFileChannel( channel, long channelPosition, byte[] dest, int destOffset, int length) throws
      read length bytes from position of a file channel.
      Parameters:
      channel - channel to read from
      channelPosition - position to read from
      dest - destination byte array to put data in
      destOffset - offset in dest to read into
      length - number of bytes to read
      Returns:
      total bytes read or -1 if an attempt was made to read past EOF. The method always tries to read all the bytes that will fit in the destination byte buffer.
      Throws:
    • readFromFileChannelWithEofException

      public static int readFromFileChannelWithEofException( channel, long channelPosition,  dest) throws
      read from a file channel into a byte buffer, starting at a certain position. An EOFException will be thrown if you attempt to read beyond the end of file.
      Parameters:
      channel - channel to read from
      channelPosition - position to read from
      dest - destination to put data in
      Returns:
      total bytes read
      Throws:
    • readFromFileChannel

      public static int readFromFileChannel( channel, long channelPosition,  dest) throws
      read from a file channel into a byte buffer, starting at a certain position.
      Parameters:
      channel - channel to read from
      channelPosition - position to read from
      dest - destination to put data in
      Returns:
      total bytes read or -1 if an attempt was made to read past EOF. The method always tries to read all the bytes that will fit in the destination byte buffer.
      Throws:
    • writeToChannel

      public static void writeToChannel(byte[] source,  channel) throws
      Writes part of a byte array to a
      Parameters:
      source - byte array to copy from
      channel - target WritableByteChannel
      Throws:
    • writeToChannel

      public static void writeToChannel(byte[] source, int offset, int length,  channel) throws
      Writes part of a byte array to a
      Parameters:
      source - byte array to copy from
      offset - start copying from this offset
      length - how many bytes to copy
      channel - target WritableByteChannel
      Throws:
    • writeToChannel

      public static void writeToChannel(byte[] source,  channel, long channelPosition) throws
      Writes part of a byte array to a at the provided position.
      Parameters:
      source - byte array to copy from
      channel - target WritableByteChannel
      channelPosition - position to write at
      Throws:
    • writeToChannel

      public static void writeToChannel(byte[] source, int offset, int length,  channel, long channelPosition) throws
      Writes part of a byte array to a at the provided position.
      Parameters:
      source - byte array to copy from
      offset - start copying from this offset
      length - how many bytes to copy
      channel - target WritableByteChannel
      channelPosition - position to write at
      Throws:
    • writeToChannel

      public static void writeToChannel( byteBuffer,  channel) throws
      Writes a to a
      Parameters:
      byteBuffer - source buffer
      channel - channel to write to
      Throws: