Created
May 3, 2012 22:20
-
-
Save groves/2589962 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void testSkip() throws Exception { | |
File test = File.createTempFile("blah", "blah"); | |
FileOutputStream out = new FileOutputStream(test); | |
out.getChannel().position(1024); | |
out.write(new byte[]{1, 2, 3, 4, 5, 6}); | |
out.getChannel().position(512); | |
out.write(new byte[]{6, 5, 4, 3, 2, 1}); | |
out.close(); | |
FileInputStream in = new FileInputStream(test); | |
System.err.println("Initial " + TestUtil.toHex(StreamUtil.readBytes(in, 6))); | |
in.skip(506); | |
System.err.println("Middle " + TestUtil.toHex(StreamUtil.readBytes(in, 6))); | |
in.skip(506); | |
System.err.println("Final " + TestUtil.toHex(StreamUtil.readBytes(in, 6))); | |
System.err.println("Next " + in.read()); | |
in.close(); | |
test.delete(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
05-03 15:19:17.067: WARN/System.err(31845): Initial 00000000 0000 | |
05-03 15:19:17.067: WARN/System.err(31845): Middle 06050403 0201 | |
05-03 15:19:17.067: WARN/System.err(31845): Final 01020304 0506 | |
05-03 15:19:17.067: WARN/System.err(31845): Next -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment