CeosFileReader { public int[] readInArray(final int arraySize, final int intValLength) throws IOException, IllegalCeosFormatException { final long streamPosition = stream.getStreamPosition(); final int[] ints = new int[arraySize]; for (int i = 0; i < ints.length; i++) { final String integerString = readAn(intValLength).trim(); if (integerString.length() > 0) { ints[i] = (int) parseLong(integerString, streamPosition + i * intValLength); } } return ints; } CeosFileReader(final ImageInputStream stream); void close(); void seek(final long pos); void skipBytes(final long numBytes); int readB1(); short readB2(); int readB4(); long readB8(); void readB4(final int[] array); void readB8(final long[] array); int readI4(); long readIn(final int n); void readB1(final byte[] array); double readFn(final int n); double readEn(final int n); double readGn(final int n); void readGn(final int n, final double[] numbers); String readAn(final int n); int[] readInArray(final int arraySize, final int intValLength); long getCurrentPos();  }
@Test public void testReadInArray() throws IOException, IllegalCeosFormatException { final String prefix = "vspdfoperilfdkposnsern"; _ios.writeBytes(prefix); _ios.writeBytes("123"); _ios.writeBytes(" 45"); _ios.writeBytes(" 6"); _ios.writeBytes(" 46"); _ios.writeBytes(" 7 "); _ios.writeBytes("234"); _ios.writeBytes("suffix"); final CeosFileReader ceosReader = new CeosFileReader(_ios); ceosReader.seek(prefix.length()); final int[] ints = ceosReader.readInArray(6, 3); assertNotNull(ints); assertEquals(6, ints.length); assertEquals(123, ints[0]); assertEquals(45, ints[1]); assertEquals(6, ints[2]); assertEquals(46, ints[3]); assertEquals(7, ints[4]); assertEquals(234, ints[5]); assertEquals(prefix.length() + 6 * 3, _ios.getStreamPosition()); }