https://issues.apache.org/bugzilla/show_bug.cgi?id=45044
Summary: CBZip2OutputStream does not work in combination with
ByteArrayOutputStream
Product: Ant
Version: 1.7.0
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: Other
AssignedTo: [email protected]
ReportedBy: [EMAIL PROTECTED]
When using a ByteArrayOutputStream in order to get an byte array of bzip2
compressed data, only the first byte is in the resulting array.
The same file with the same code with a FileOutputStream however works fine.
You can use this code to reproduce the error (hope it compiles):
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
CBZip2OutputStream outFail = new CBZip2OutputStream(byteOut);
FileOutputStream fos = new FileOutputStream("C:\\test.bz2");
CBZip2OutputStream outOk = new CBZip2OutputStream(fos);
byte[] bs = new byte[1024];
int l = in.read(bs);
while (l == 1024)
{
outFail.write(bs);
outOk.write(bs);
l = in.read(bs);
}
if (l > 0)
{
outFail.write(bs, 0, l);
outOk.write(bs, 0, l);
}
outFail.flush();
outOk.flush();
in.close();
// FAIL
// at this point, byteOut.toByteArray() has always length 1
outFail.close();
outOk.close();
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.