Package org.elasticsearch.common.io
Class Channels
org.elasticsearch.common.io.Channels
public final class Channels
extends
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
The maximum chunk size for writes in bytes -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 channelstatic 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 astatic 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 astatic void
byteBuffer, channel)
Writes a to aMethods inherited from class java.lang.
, , , , , , , , , ,
-
Field Details
-
WRITE_CHUNK_SIZE
public static final int WRITE_CHUNK_SIZEThe maximum chunk size for writes in bytes- See Also:
- Constant Field Values
-
-
Method Details
-
readFromFileChannel
public static byte[] readFromFileChannel( channel, long position, int length) throwsread length bytes from position of a file channel- Throws:
-
readFromFileChannelWithEofException
public static void readFromFileChannelWithEofException( channel, long channelPosition, byte[] dest, int destOffset, int length) throwsread 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 fromchannelPosition
- position to read fromdest
- destination byte array to put data indestOffset
- offset in dest to read intolength
- number of bytes to read- Throws:
-
readFromFileChannel
public static int readFromFileChannel( channel, long channelPosition, byte[] dest, int destOffset, int length) throwsread length bytes from position of a file channel.- Parameters:
channel
- channel to read fromchannelPosition
- position to read fromdest
- destination byte array to put data indestOffset
- offset in dest to read intolength
- 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) throwsread 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 fromchannelPosition
- position to read fromdest
- destination to put data in- Returns:
- total bytes read
- Throws:
-
readFromFileChannel
public static int readFromFileChannel( channel, long channelPosition, dest) throwsread from a file channel into a byte buffer, starting at a certain position.- Parameters:
channel
- channel to read fromchannelPosition
- position to read fromdest
- 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) throwsWrites part of a byte array to a- Parameters:
source
- byte array to copy fromchannel
- target WritableByteChannel- Throws:
-
writeToChannel
public static void writeToChannel(byte[] source, int offset, int length, channel) throwsWrites part of a byte array to a- Parameters:
source
- byte array to copy fromoffset
- start copying from this offsetlength
- how many bytes to copychannel
- target WritableByteChannel- Throws:
-
writeToChannel
public static void writeToChannel(byte[] source, channel, long channelPosition) throwsWrites part of a byte array to a at the provided position.- Parameters:
source
- byte array to copy fromchannel
- target WritableByteChannelchannelPosition
- position to write at- Throws:
-
writeToChannel
public static void writeToChannel(byte[] source, int offset, int length, channel, long channelPosition) throwsWrites part of a byte array to a at the provided position.- Parameters:
source
- byte array to copy fromoffset
- start copying from this offsetlength
- how many bytes to copychannel
- target WritableByteChannelchannelPosition
- position to write at- Throws:
-
writeToChannel
public static void writeToChannel( byteBuffer, channel) throwsWrites a to a- Parameters:
byteBuffer
- source bufferchannel
- channel to write to- Throws:
-