From 02eaa945356e87d7b3c69179bdb2cd7fd17a4e53 Mon Sep 17 00:00:00 2001 From: Avik Sengupta Date: Thu, 31 Jul 2003 19:36:37 +0000 Subject: [PATCH] Slow input stream patch, bug 13478 Thanks Tony Chao and Chris Nokleberg git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/REL_2_BRANCH@353277 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/poifs/storage/DocumentBlock.java | 3 ++- src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java | 3 ++- src/java/org/apache/poi/poifs/storage/RawDataBlock.java | 3 ++- .../org/apache/poi/poifs/filesystem/TestDocument.java | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/poi/poifs/storage/DocumentBlock.java b/src/java/org/apache/poi/poifs/storage/DocumentBlock.java index f6d0d92b4..7af3487fa 100644 --- a/src/java/org/apache/poi/poifs/storage/DocumentBlock.java +++ b/src/java/org/apache/poi/poifs/storage/DocumentBlock.java @@ -62,6 +62,7 @@ import java.io.OutputStream; import java.util.Arrays; import org.apache.poi.poifs.common.POIFSConstants; +import org.apache.poi.util.IOUtils; import org.apache.poi.util.IntegerField; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndianConsts; @@ -106,7 +107,7 @@ public class DocumentBlock throws IOException { this(); - int count = stream.read(_data); + int count = IOUtils.readFully(stream, _data); _bytes_read = (count == -1) ? 0 : count; diff --git a/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java b/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java index 015d455d2..ad7736851 100644 --- a/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java +++ b/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java @@ -60,6 +60,7 @@ import java.io.*; import java.util.*; import org.apache.poi.poifs.common.POIFSConstants; +import org.apache.poi.util.IOUtils; import org.apache.poi.util.IntegerField; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndianConsts; @@ -104,7 +105,7 @@ public class HeaderBlockReader throws IOException { _data = new byte[ POIFSConstants.BIG_BLOCK_SIZE ]; - int byte_count = stream.read(_data); + int byte_count = IOUtils.readFully(stream, _data); if (byte_count != POIFSConstants.BIG_BLOCK_SIZE) { diff --git a/src/java/org/apache/poi/poifs/storage/RawDataBlock.java b/src/java/org/apache/poi/poifs/storage/RawDataBlock.java index 862fd8ca2..863b6108e 100644 --- a/src/java/org/apache/poi/poifs/storage/RawDataBlock.java +++ b/src/java/org/apache/poi/poifs/storage/RawDataBlock.java @@ -56,6 +56,7 @@ package org.apache.poi.poifs.storage; import org.apache.poi.poifs.common.POIFSConstants; +import org.apache.poi.util.IOUtils; import java.io.*; @@ -84,7 +85,7 @@ public class RawDataBlock throws IOException { _data = new byte[ POIFSConstants.BIG_BLOCK_SIZE ]; - int count = stream.read(_data); + int count = IOUtils.readFully(stream, _data); if (count == -1) { diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java b/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java index af417fad1..2e9fd0282 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java @@ -107,7 +107,7 @@ public class TestDocument { array[ j ] = ( byte ) j; } - document = new POIFSDocument("foo", new ByteArrayInputStream(array)); + document = new POIFSDocument("foo", new SlowInputStream(new ByteArrayInputStream(array))); checkDocument(document, array); // verify correct number of blocks get created for document