protected void testSeekSkip(SeekableInputStream pSeekable, String pStr) throws IOException { System.out.println(); pSeekable.seek(pStr.length()); FileUtil.read(pSeekable); for (int i = 0; i < 10; i++) { byte[] bytes = FileUtil.read(pSeekable); int len = bytes.length; if (len != 0) { System.err.println("Error in buffer length after full read..."); System.err.println("len: " + len); System.err.println("bytes: \"" + new String(bytes) + "\""); break; } } System.out.println(); for (int i = 0; i < 10; i++) { pSeekable.seek(0); int skip = i * 3; //noinspection ResultOfMethodCallIgnored pSeekable.skip(skip); String str = new String(FileUtil.read(pSeekable)); System.out.println(str); if (str.length() != pStr.length() - skip) { throw new Error("Error in buffer length after skip"); } } System.out.println(); System.out.println("seek/skip ok!"); System.out.println(); }
@Test public void testSeekSkipRead() throws Exception { SeekableInputStream seekable = makeInputStream(133); int pos = 45; for (int i = 0; i < 10; i++) { seekable.seek(pos); //noinspection ResultOfMethodCallIgnored seekable.skip(i); byte[] bytes = FileUtil.read(seekable); assertEquals(133, seekable.getStreamPosition()); assertEquals(133 - 45- i, bytes.length); } }
protected void testSeekSkip(SeekableInputStream pSeekable, String pStr) throws IOException { System.out.println(); pSeekable.seek(pStr.length()); FileUtil.read(pSeekable); for (int i = 0; i < 10; i++) { byte[] bytes = FileUtil.read(pSeekable); int len = bytes.length; if (len != 0) { System.err.println("Error in buffer length after full read..."); System.err.println("len: " + len); System.err.println("bytes: \"" + new String(bytes) + "\""); break; } } System.out.println(); for (int i = 0; i < 10; i++) { pSeekable.seek(0); int skip = i * 3; //noinspection ResultOfMethodCallIgnored pSeekable.skip(skip); String str = new String(FileUtil.read(pSeekable)); System.out.println(str); if (str.length() != pStr.length() - skip) { throw new Error("Error in buffer length after skip"); } } System.out.println(); System.out.println("seek/skip ok!"); System.out.println(); }
public void testSeekSkip(SeekableInputStream pSeekable, String pStr) throws IOException { System.out.println(); pSeekable.seek(pStr.length()); FileUtil.read(pSeekable); for (int i = 0; i < 10; i++) { byte[] bytes = FileUtil.read(pSeekable); int len = bytes.length; if (len != 0) { System.err.println("Error in buffer length after full read..."); System.err.println("len: " + len); System.err.println("bytes: \"" + new String(bytes) + "\""); break; } } System.out.println(); for (int i = 0; i < 10; i++) { pSeekable.seek(0); int skip = i * 3; //noinspection ResultOfMethodCallIgnored pSeekable.skip(skip); String str = new String(FileUtil.read(pSeekable)); System.out.println(str); if (str.length() != pStr.length() - skip) { throw new Error("Error in buffer length after skip"); } } System.out.println(); System.out.println("seek/skip ok!"); System.out.println(); }
public void testSeekSkipRead() throws Exception { SeekableInputStream seekable = makeInputStream(133); int pos = 45; for (int i = 0; i < 10; i++) { seekable.seek(pos); //noinspection ResultOfMethodCallIgnored seekable.skip(i); byte[] bytes = FileUtil.read(seekable); assertEquals(133, seekable.getStreamPosition()); assertEquals(133 - 45- i, bytes.length); } }
@Test public void testSeekSkipRead() throws Exception { SeekableInputStream seekable = makeInputStream(133); int pos = 45; for (int i = 0; i < 10; i++) { seekable.seek(pos); //noinspection ResultOfMethodCallIgnored seekable.skip(i); byte[] bytes = FileUtil.read(seekable); assertEquals(133, seekable.getStreamPosition()); assertEquals(133 - 45- i, bytes.length); } }