An Input for files.
| 25 | |
| 26 | /** An {@link Input} for files. */ |
| 27 | public class InputFile implements Input { |
| 28 | |
| 29 | private FileChannel channel; |
| 30 | |
| 31 | /** Construct for the given file. */ |
| 32 | public InputFile(File file) throws IOException { |
| 33 | this.channel = new FileInputStream(file).getChannel(); |
| 34 | } |
| 35 | |
| 36 | @Override |
| 37 | public long length() throws IOException { |
| 38 | return channel.size(); |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public int read(long position, byte[] b, int start, int len) throws IOException { |
| 43 | return channel.read(ByteBuffer.wrap(b, start, len), position); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public void close() throws IOException { |
| 48 | channel.close(); |
| 49 | } |
| 50 | |
| 51 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…