### Question:
StreamFile extends DfsServlet { static void copyFromOffset(FSInputStream in, OutputStream out, long offset, long count) throws IOException { in.seek(offset); IOUtils.copyBytes(in, out, count, false); }  @Override @SuppressWarnings("unchecked") void doGet(HttpServletRequest request, HttpServletResponse response); static final String CONTENT_LENGTH; }### Answer:
@Test public void testWriteTo() throws IOException { FSInputStream fsin = new MockFSInputStream(); ByteArrayOutputStream os = new ByteArrayOutputStream(); int[] pairs = new int[]{ 0, 10000, 50, 100, 50, 6000, 1000, 2000, 0, 1, 0, 0, 5000, 0, }; assertTrue("Pairs array must be even", pairs.length % 2 == 0); for (int i = 0; i < pairs.length; i+=2) { StreamFile.copyFromOffset(fsin, os, pairs[i], pairs[i+1]); assertArrayEquals("Reading " + pairs[i+1] + " bytes from offset " + pairs[i], getOutputArray(pairs[i], pairs[i+1]), os.toByteArray()); os.reset(); } }