ChunkedNioFile Class — netty Architecture
Architecture documentation for the ChunkedNioFile class in ChunkedNioFile.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b26fa483_4061_d8f6_cd9f_e08460cd6a25["ChunkedNioFile"] 19d717c8_37f3_0983_fbe8_3e56e6d8ab1c["ChunkedNioFile.java"] b26fa483_4061_d8f6_cd9f_e08460cd6a25 -->|defined in| 19d717c8_37f3_0983_fbe8_3e56e6d8ab1c 5d9f636e_a269_0c9a_4e4c_242f334bb6b4["ChunkedNioFile()"] b26fa483_4061_d8f6_cd9f_e08460cd6a25 -->|method| 5d9f636e_a269_0c9a_4e4c_242f334bb6b4 1a8f2290_e1f0_8ca3_cdfe_425a1a7702ed["startOffset()"] b26fa483_4061_d8f6_cd9f_e08460cd6a25 -->|method| 1a8f2290_e1f0_8ca3_cdfe_425a1a7702ed 2422a4ef_0cf8_a9b1_5118_cfa8ed6ad533["endOffset()"] b26fa483_4061_d8f6_cd9f_e08460cd6a25 -->|method| 2422a4ef_0cf8_a9b1_5118_cfa8ed6ad533 781d75bb_0904_8cfc_c2a9_9cc9f7a71b39["currentOffset()"] b26fa483_4061_d8f6_cd9f_e08460cd6a25 -->|method| 781d75bb_0904_8cfc_c2a9_9cc9f7a71b39 e618a676_ae1d_9f41_d640_46db2831567c["isEndOfInput()"] b26fa483_4061_d8f6_cd9f_e08460cd6a25 -->|method| e618a676_ae1d_9f41_d640_46db2831567c ca07c5a0_b63b_b947_ad7c_dd9fd6c68feb["close()"] b26fa483_4061_d8f6_cd9f_e08460cd6a25 -->|method| ca07c5a0_b63b_b947_ad7c_dd9fd6c68feb f0b5d1f9_dcb9_3620_0353_cca9b87f6431["ByteBuf()"] b26fa483_4061_d8f6_cd9f_e08460cd6a25 -->|method| f0b5d1f9_dcb9_3620_0353_cca9b87f6431 d2f6d677_5989_d735_381f_f3809cd9c82e["length()"] b26fa483_4061_d8f6_cd9f_e08460cd6a25 -->|method| d2f6d677_5989_d735_381f_f3809cd9c82e 1fdd0c77_e708_d7bb_9d67_ea8f5cda6a9f["progress()"] b26fa483_4061_d8f6_cd9f_e08460cd6a25 -->|method| 1fdd0c77_e708_d7bb_9d67_ea8f5cda6a9f
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/stream/ChunkedNioFile.java lines 38–181
public class ChunkedNioFile implements ChunkedInput<ByteBuf> {
private final FileChannel in;
private final long startOffset;
private final long endOffset;
private final int chunkSize;
private long offset;
/**
* Creates a new instance that fetches data from the specified file.
*/
public ChunkedNioFile(File in) throws IOException {
this(new RandomAccessFile(in, "r").getChannel());
}
/**
* Creates a new instance that fetches data from the specified file.
*
* @param chunkSize the number of bytes to fetch on each
* {@link #readChunk(ChannelHandlerContext)} call
*/
public ChunkedNioFile(File in, int chunkSize) throws IOException {
this(new RandomAccessFile(in, "r").getChannel(), chunkSize);
}
/**
* Creates a new instance that fetches data from the specified file.
*/
public ChunkedNioFile(FileChannel in) throws IOException {
this(in, ChunkedStream.DEFAULT_CHUNK_SIZE);
}
/**
* Creates a new instance that fetches data from the specified file.
*
* @param chunkSize the number of bytes to fetch on each
* {@link #readChunk(ChannelHandlerContext)} call
*/
public ChunkedNioFile(FileChannel in, int chunkSize) throws IOException {
this(in, 0, in.size(), chunkSize);
}
/**
* Creates a new instance that fetches data from the specified file.
*
* @param offset the offset of the file where the transfer begins
* @param length the number of bytes to transfer
* @param chunkSize the number of bytes to fetch on each
* {@link #readChunk(ChannelHandlerContext)} call
*/
public ChunkedNioFile(FileChannel in, long offset, long length, int chunkSize)
throws IOException {
ObjectUtil.checkNotNull(in, "in");
ObjectUtil.checkPositiveOrZero(offset, "offset");
ObjectUtil.checkPositiveOrZero(length, "length");
ObjectUtil.checkPositive(chunkSize, "chunkSize");
if (!in.isOpen()) {
throw new ClosedChannelException();
}
this.in = in;
this.chunkSize = chunkSize;
this.offset = startOffset = offset;
endOffset = offset + length;
}
/**
* Returns the offset in the file where the transfer began.
*/
public long startOffset() {
return startOffset;
}
/**
* Returns the offset in the file where the transfer will end.
*/
public long endOffset() {
return endOffset;
}
/**
* Returns the offset in the file where the transfer is happening currently.
Source
Frequently Asked Questions
What is the ChunkedNioFile class?
ChunkedNioFile is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/stream/ChunkedNioFile.java.
Where is ChunkedNioFile defined?
ChunkedNioFile is defined in handler/src/main/java/io/netty/handler/stream/ChunkedNioFile.java at line 38.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free