From 8095869530b1be3e263d5c441e61e56a4c79af59 Mon Sep 17 00:00:00 2001 From: mjohnson Date: Wed, 20 Feb 2002 01:19:26 +0000 Subject: [PATCH] fix bug in read() method git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352111 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/poifs/filesystem/DocumentInputStream.java | 2 +- .../apache/poi/poifs/filesystem/TestDocumentInputStream.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java b/src/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java index 0f581aa36..db152cef8 100644 --- a/src/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java +++ b/src/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java @@ -236,7 +236,7 @@ public class DocumentInputStream _tiny_buffer = new byte[ 1 ]; } _document.read(_tiny_buffer, _current_offset++); - return _tiny_buffer[ 0 ]; + return ((int)_tiny_buffer[ 0 ]) & 0x000000FF; } /** diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java b/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java index e77fee566..f3c15227c 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java @@ -217,8 +217,10 @@ public class TestDocumentInputStream 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 ], - ( byte ) stream.read()); + ( byte ) b); remaining--; assertEquals("checking remaining after reading byte " + j, remaining, stream.available());