| 3 | |
| 4 | public class FindRRTest { |
| 5 | public static void main(String[] args) throws Exception { |
| 6 | BufferedInputStream bis = null; |
| 7 | try { |
| 8 | byte[] buffer = new byte[100]; |
| 9 | for (int i = 0; i < 100; i++) |
| 10 | buffer[i] = (byte) i; |
| 11 | ByteArrayInputStream bais = new ByteArrayInputStream(buffer); |
| 12 | bis = new BufferedInputStream(bais, 50); |
| 13 | |
| 14 | byte[] smallBuf = new byte[10]; |
| 15 | |
| 16 | bis.read(smallBuf); |
| 17 | System.out.println(bis.available()); |
| 18 | long s = bis.skip(50); |
| 19 | System.out.println(s); |
| 20 | bis.read(smallBuf); |
| 21 | |
| 22 | System.out.println(smallBuf[0]); |
| 23 | if (smallBuf[0] == 60) |
| 24 | System.out.println("It works"); |
| 25 | else |
| 26 | throw new Exception("Better check the size returned by skip(): read " + smallBuf[0]); |
| 27 | } finally { |
| 28 | if (bis != null) |
| 29 | bis.close(); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | } |