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
This commit is contained in:
Avik Sengupta 2003-07-31 19:36:37 +00:00
parent 250442a0a2
commit 02eaa94535
4 changed files with 7 additions and 4 deletions

View File

@ -62,6 +62,7 @@ import java.io.OutputStream;
import java.util.Arrays; import java.util.Arrays;
import org.apache.poi.poifs.common.POIFSConstants; import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.IntegerField; import org.apache.poi.util.IntegerField;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts; import org.apache.poi.util.LittleEndianConsts;
@ -106,7 +107,7 @@ public class DocumentBlock
throws IOException throws IOException
{ {
this(); this();
int count = stream.read(_data); int count = IOUtils.readFully(stream, _data);
_bytes_read = (count == -1) ? 0 _bytes_read = (count == -1) ? 0
: count; : count;

View File

@ -60,6 +60,7 @@ import java.io.*;
import java.util.*; import java.util.*;
import org.apache.poi.poifs.common.POIFSConstants; import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.IntegerField; import org.apache.poi.util.IntegerField;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts; import org.apache.poi.util.LittleEndianConsts;
@ -104,7 +105,7 @@ public class HeaderBlockReader
throws IOException throws IOException
{ {
_data = new byte[ POIFSConstants.BIG_BLOCK_SIZE ]; _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) if (byte_count != POIFSConstants.BIG_BLOCK_SIZE)
{ {

View File

@ -56,6 +56,7 @@
package org.apache.poi.poifs.storage; package org.apache.poi.poifs.storage;
import org.apache.poi.poifs.common.POIFSConstants; import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.util.IOUtils;
import java.io.*; import java.io.*;
@ -84,7 +85,7 @@ public class RawDataBlock
throws IOException throws IOException
{ {
_data = new byte[ POIFSConstants.BIG_BLOCK_SIZE ]; _data = new byte[ POIFSConstants.BIG_BLOCK_SIZE ];
int count = stream.read(_data); int count = IOUtils.readFully(stream, _data);
if (count == -1) if (count == -1)
{ {

View File

@ -107,7 +107,7 @@ public class TestDocument
{ {
array[ j ] = ( byte ) j; array[ j ] = ( byte ) j;
} }
document = new POIFSDocument("foo", new ByteArrayInputStream(array)); document = new POIFSDocument("foo", new SlowInputStream(new ByteArrayInputStream(array)));
checkDocument(document, array); checkDocument(document, array);
// verify correct number of blocks get created for document // verify correct number of blocks get created for document