ChunkedFile Class — netty Architecture
Architecture documentation for the ChunkedFile class in ChunkedFile.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD bc8c9320_7433_7cc8_0313_7128cb67f2b5["ChunkedFile"] 28d92fd6_5a84_c14c_39ac_6989435092ca["ChunkedFile.java"] bc8c9320_7433_7cc8_0313_7128cb67f2b5 -->|defined in| 28d92fd6_5a84_c14c_39ac_6989435092ca 843da289_d5aa_2c07_018a_11e71db83f6e["ChunkedFile()"] bc8c9320_7433_7cc8_0313_7128cb67f2b5 -->|method| 843da289_d5aa_2c07_018a_11e71db83f6e efb1640d_e400_881a_15f0_05bd0b690b22["startOffset()"] bc8c9320_7433_7cc8_0313_7128cb67f2b5 -->|method| efb1640d_e400_881a_15f0_05bd0b690b22 86316a32_a796_86d1_f5c6_daec908f1680["endOffset()"] bc8c9320_7433_7cc8_0313_7128cb67f2b5 -->|method| 86316a32_a796_86d1_f5c6_daec908f1680 46bdfa9c_9c70_591a_1374_22508322b097["currentOffset()"] bc8c9320_7433_7cc8_0313_7128cb67f2b5 -->|method| 46bdfa9c_9c70_591a_1374_22508322b097 3e76d117_62d4_f43d_937a_038f1f14fa28["isEndOfInput()"] bc8c9320_7433_7cc8_0313_7128cb67f2b5 -->|method| 3e76d117_62d4_f43d_937a_038f1f14fa28 34609365_5bf4_51da_a8ad_3975005c5d12["close()"] bc8c9320_7433_7cc8_0313_7128cb67f2b5 -->|method| 34609365_5bf4_51da_a8ad_3975005c5d12 f643c78f_76dc_1d7e_c501_ddb35bf09877["ByteBuf()"] bc8c9320_7433_7cc8_0313_7128cb67f2b5 -->|method| f643c78f_76dc_1d7e_c501_ddb35bf09877 2e767005_560d_8c10_b23d_599240cdf3ee["length()"] bc8c9320_7433_7cc8_0313_7128cb67f2b5 -->|method| 2e767005_560d_8c10_b23d_599240cdf3ee 7ec2f2d9_3f21_c1a4_bc86_81f02f1b7e08["progress()"] bc8c9320_7433_7cc8_0313_7128cb67f2b5 -->|method| 7ec2f2d9_3f21_c1a4_bc86_81f02f1b7e08
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/stream/ChunkedFile.java lines 35–170
public class ChunkedFile implements ChunkedInput<ByteBuf> {
private final RandomAccessFile file;
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 ChunkedFile(File file) throws IOException {
this(file, 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 ChunkedFile(File file, int chunkSize) throws IOException {
this(new RandomAccessFile(file, "r"), chunkSize);
}
/**
* Creates a new instance that fetches data from the specified file.
*/
public ChunkedFile(RandomAccessFile file) throws IOException {
this(file, 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 ChunkedFile(RandomAccessFile file, int chunkSize) throws IOException {
this(file, 0, file.length(), 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 ChunkedFile(RandomAccessFile file, long offset, long length, int chunkSize) throws IOException {
ObjectUtil.checkNotNull(file, "file");
ObjectUtil.checkPositiveOrZero(offset, "offset");
ObjectUtil.checkPositiveOrZero(length, "length");
ObjectUtil.checkPositive(chunkSize, "chunkSize");
this.file = file;
this.offset = startOffset = offset;
this.endOffset = offset + length;
this.chunkSize = chunkSize;
file.seek(offset);
}
/**
* 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 ChunkedFile class?
ChunkedFile is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/stream/ChunkedFile.java.
Where is ChunkedFile defined?
ChunkedFile is defined in handler/src/main/java/io/netty/handler/stream/ChunkedFile.java at line 35.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free