diff --git a/examples/src/test/java/org/apache/wink/client/MockHttpServer.java b/examples/src/test/java/org/apache/wink/client/MockHttpServer.java index 305a9f87cc8..cbf153db5cb 100644 --- a/examples/src/test/java/org/apache/wink/client/MockHttpServer.java +++ b/examples/src/test/java/org/apache/wink/client/MockHttpServer.java @@ -41,8 +41,6 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; -import org.apache.pdfbox.io.IOUtils; - /** * Copied from * http://svn.apache.org/repos/asf/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/client/MockHttpServer.java @@ -335,8 +333,7 @@ private void processRegularContent(InputStream is) throws IOException { return; } int contentLen = Integer.parseInt(contentLength); - byte[] bytes = new byte[contentLen]; - IOUtils.populateBuffer(is, bytes); + byte[] bytes = is.readNBytes(contentLen); requestContent.write(bytes); } diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java index 9d4a02068cf..2a99e65f02e 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java @@ -406,7 +406,7 @@ private boolean prepareAESInitializationVector(boolean decrypt, byte[] iv, Input if (decrypt) { // read IV from stream - int ivSize = (int) IOUtils.populateBuffer(data, iv); + int ivSize = data.readNBytes(iv, 0, iv.length); if (ivSize == 0) { return false; @@ -515,10 +515,11 @@ public void decryptStream(COSStream stream, long objNum, long genNum) throws IOE // PDFBOX-3229 check case where metadata is not encrypted despite /EncryptMetadata missing try (InputStream is = stream.createRawInputStream()) { - buf = new byte[10]; - long isResult = IOUtils.populateBuffer(is, buf); + int nBytes = 10; + buf = is.readNBytes(nBytes); + int isResult = buf.length; - if (Long.compare(isResult, buf.length) != 0) + if (buf.length != nBytes) { LOG.debug("Tried reading " + buf.length + " bytes but only " + isResult + " bytes read"); } diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/SampledImageReader.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/SampledImageReader.java index 9563100f78b..c08e6f65aff 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/SampledImageReader.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/SampledImageReader.java @@ -35,7 +35,6 @@ import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSNumber; import org.apache.pdfbox.filter.DecodeOptions; -import org.apache.pdfbox.io.IOUtils; import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace; import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceGray; import org.apache.pdfbox.pdmodel.graphics.color.PDIndexed; @@ -98,7 +97,7 @@ public static BufferedImage getStencilImage(PDImage pdImage, Paint paint) throws for (int y = 0; y < height; y++) { int x = 0; - int readLen = (int) IOUtils.populateBuffer(iis, buff); + int readLen = iis.readNBytes(buff, 0, buff.length); for (int r = 0; r < rowLen && r < readLen; r++) { int byteValue = buff[r]; @@ -421,7 +420,7 @@ private static BufferedImage from1Bit(PDImage pdImage, Rectangle clipped, final final byte[] buff = new byte[stride]; for (int y = 0; y < starty + scanHeight; y++) { - int read = (int) IOUtils.populateBuffer(iis, buff); + int read = iis.readNBytes(buff, 0, buff.length); if (y >= starty && y % currentSubsampling == 0) { int x = startx; @@ -498,8 +497,8 @@ private static BufferedImage from8bit(PDImage pdImage, WritableRaster raster, Re if (startx == 0 && starty == 0 && scanWidth == width && scanHeight == height && currentSubsampling == 1) { // we just need to copy all sample data, then convert to RGB image. - long inputResult = IOUtils.populateBuffer(input, bank); - if (Long.compare(inputResult, (long) width * height * numComponents) != 0) + int inputResult = input.readNBytes(bank, 0, bank.length); + if (inputResult != (long) width * height * numComponents) { LOG.debug("Tried reading " + (long) width * height * numComponents + " bytes but only " + inputResult + " bytes read"); } @@ -515,7 +514,7 @@ private static BufferedImage from8bit(PDImage pdImage, WritableRaster raster, Re int i = 0; for (int y = 0; y < starty + scanHeight; ++y) { - long inputResult = IOUtils.populateBuffer(input, tempBytes); + int inputResult = input.readNBytes(tempBytes, 0, tempBytes.length); if (Long.compare(inputResult, tempBytes.length) != 0) {