@Test public void testPipe_Underrun() { int dataLength = 10; ByteArrayInputStream in = new ByteArrayInputStream(new byte[dataLength]); try { BsPatch.pipe(in, new ByteArrayOutputStream(), new byte[dataLength], dataLength + 1); Assert.fail("Should've thrown an IOException"); } catch (IOException expected) { } }
static void pipe( final InputStream in, final OutputStream out, final byte[] buffer, int copyLength) throws IOException { while (copyLength > 0) { int maxCopy = Math.min(buffer.length, copyLength); readFully(in, buffer, 0, maxCopy); out.write(buffer, 0, maxCopy); copyLength -= maxCopy; } }
BsPatch { static void pipe( final InputStream in, final OutputStream out, final byte[] buffer, int copyLength) throws IOException { while (copyLength > 0) { int maxCopy = Math.min(buffer.length, copyLength); readFully(in, buffer, 0, maxCopy); out.write(buffer, 0, maxCopy); copyLength -= maxCopy; } } }
BsPatch { static void pipe( final InputStream in, final OutputStream out, final byte[] buffer, int copyLength) throws IOException { while (copyLength > 0) { int maxCopy = Math.min(buffer.length, copyLength); readFully(in, buffer, 0, maxCopy); out.write(buffer, 0, maxCopy); copyLength -= maxCopy; } }  }
BsPatch { static void pipe( final InputStream in, final OutputStream out, final byte[] buffer, int copyLength) throws IOException { while (copyLength > 0) { int maxCopy = Math.min(buffer.length, copyLength); readFully(in, buffer, 0, maxCopy); out.write(buffer, 0, maxCopy); copyLength -= maxCopy; } }  static void applyPatch(
      RandomAccessFile oldData, OutputStream newData, InputStream patchData); }
BsPatch { static void pipe( final InputStream in, final OutputStream out, final byte[] buffer, int copyLength) throws IOException { while (copyLength > 0) { int maxCopy = Math.min(buffer.length, copyLength); readFully(in, buffer, 0, maxCopy); out.write(buffer, 0, maxCopy); copyLength -= maxCopy; } }  static void applyPatch(
      RandomAccessFile oldData, OutputStream newData, InputStream patchData);  }