fix bug in read() method

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352111 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
mjohnson 2002-02-20 01:19:26 +00:00
parent 48a768050e
commit 8095869530
2 changed files with 4 additions and 2 deletions

View File

@ -236,7 +236,7 @@ public class DocumentInputStream
_tiny_buffer = new byte[ 1 ]; _tiny_buffer = new byte[ 1 ];
} }
_document.read(_tiny_buffer, _current_offset++); _document.read(_tiny_buffer, _current_offset++);
return _tiny_buffer[ 0 ]; return ((int)_tiny_buffer[ 0 ]) & 0x000000FF;
} }
/** /**

View File

@ -217,8 +217,10 @@ public class TestDocumentInputStream
for (int j = 0; j < _workbook_size; j++) for (int j = 0; j < _workbook_size; j++)
{ {
int b = stream.read();
assertTrue("checking sign of " + j, b >= 0);
assertEquals("validating byte " + j, _workbook_data[ j ], assertEquals("validating byte " + j, _workbook_data[ j ],
( byte ) stream.read()); ( byte ) b);
remaining--; remaining--;
assertEquals("checking remaining after reading byte " + j, assertEquals("checking remaining after reading byte " + j,
remaining, stream.available()); remaining, stream.available());