mirror of https://github.com/apache/poi.git
Empty byte array case for HexDump
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353579 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7abc766ebb
commit
3a59e361ff
|
@ -73,6 +73,12 @@ public class HexDump
|
||||||
throws IOException, ArrayIndexOutOfBoundsException,
|
throws IOException, ArrayIndexOutOfBoundsException,
|
||||||
IllegalArgumentException
|
IllegalArgumentException
|
||||||
{
|
{
|
||||||
|
if (data.length == 0)
|
||||||
|
{
|
||||||
|
stream.write( "No Data".getBytes() );
|
||||||
|
stream.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ((index < 0) || (index >= data.length))
|
if ((index < 0) || (index >= data.length))
|
||||||
{
|
{
|
||||||
throw new ArrayIndexOutOfBoundsException(
|
throw new ArrayIndexOutOfBoundsException(
|
||||||
|
@ -83,6 +89,7 @@ public class HexDump
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("cannot write to nullstream");
|
throw new IllegalArgumentException("cannot write to nullstream");
|
||||||
}
|
}
|
||||||
|
|
||||||
long display_offset = offset + index;
|
long display_offset = offset + index;
|
||||||
StringBuffer buffer = new StringBuffer(74);
|
StringBuffer buffer = new StringBuffer(74);
|
||||||
|
|
||||||
|
|
|
@ -277,6 +277,11 @@ public class TestHexDump
|
||||||
|
|
||||||
// as expected
|
// as expected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// verify proper behaviour with empty byte array
|
||||||
|
ByteArrayOutputStream os = new ByteArrayOutputStream( );
|
||||||
|
HexDump.dump( new byte[0], 0, os, 0 );
|
||||||
|
assertEquals( "No Data", os.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testToHex()
|
public void testToHex()
|
||||||
|
|
Loading…
Reference in New Issue