@Test public void getByIndexTest() throws IOException { File file = new File(SOURCE_FILE); try (RandomAccessFile raf = FileUtil.getRandomAccessFile(file)) { RAFRandomAccessSource source = new RAFRandomAccessSource(raf); for (int i = 0; i < content.length; i++) { Assert.assertEquals(content[i], source.get(i)); } } }
public int get(long position) throws java.io.IOException { if (position > length) return -1; if (raf.getFilePointer() != position) { raf.seek(position); } return raf.read(); }
RAFRandomAccessSource implements IRandomAccessSource { public int get(long position) throws java.io.IOException { if (position > length) return -1; if (raf.getFilePointer() != position) { raf.seek(position); } return raf.read(); } }
RAFRandomAccessSource implements IRandomAccessSource { public int get(long position) throws java.io.IOException { if (position > length) return -1; if (raf.getFilePointer() != position) { raf.seek(position); } return raf.read(); } RAFRandomAccessSource(RandomAccessFile raf); }
RAFRandomAccessSource implements IRandomAccessSource { public int get(long position) throws java.io.IOException { if (position > length) return -1; if (raf.getFilePointer() != position) { raf.seek(position); } return raf.read(); } RAFRandomAccessSource(RandomAccessFile raf); int get(long position); int get(long position, byte[] bytes, int off, int len); long length(); void close(); }
RAFRandomAccessSource implements IRandomAccessSource { public int get(long position) throws java.io.IOException { if (position > length) return -1; if (raf.getFilePointer() != position) { raf.seek(position); } return raf.read(); } RAFRandomAccessSource(RandomAccessFile raf); int get(long position); int get(long position, byte[] bytes, int off, int len); long length(); void close();  }