Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > BZip2 Compression with Apache Ant's BZip2 tools.....problem

Reply
Thread Tools

BZip2 Compression with Apache Ant's BZip2 tools.....problem

 
 
TSchultz55
Guest
Posts: n/a
 
      07-26-2005
All,

I'm having some problems with Apache Ant's BZip2 classes.
Hopefully someone can help me out. Every time I open a *.bz2 file that
my class generates, it says "Invalid Archive" (using 7-Zip). 7-Zip can
open *.bz2 files, as I have successfully done many times. Here's the
code (all variables have been defined):

byte[] fileBytes = new byte[1024];
...............
public File compress(File currentChunkFile) throws IOException
{
File compressedFile = new File(currentChunkFile.getParent(),
currentChunkFile.getName() + ".bz2");
fileIn = new FileInputStream(currentChunkFile);
bzip2Out = new CBZip2OutputStream(new
FileOutputStream(compressedFile));
int readBytes = 0;

while((readBytes = fileIn.read(fileBytes, 0, fileBytes.length)) > -1)
{
bzip2Out.write(fileBytes, 0, readBytes);
}

// Cleanup
bzip2Out.flush();
fileIn.close();
bzip2Out.close();

return compressedFile;
}
.......................
I use the same exact logic for GZip compression and that works fine. A
*.bz2 file generated by my class is always a few bytes smaller than on
generated by bzip2.exe. Why is this? Is there an issue with this
Apache library? Is there some dumb error in the code I don't see? Can
anyone point me in the direction of a better BZip2 compression library?
Any help would be greatly appreciated. Thanks!

Cheers,

Tim

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Javascript Obfuscator & compression Apache module? Chetan Patil Javascript 5 04-01-2006 02:54 AM
(Python newbie) Using XP-SP2/MSVC6: No Python24_d.lib, winzip barfs on Python-2.4.1.tar, cannot download bzip2 Bill Davy Python 12 04-22-2005 12:19 PM
Re: (Python newbie) Using XP-SP2/MSVC6: No Python24_d.lib,winzip barfs on Python-2.4.1.tar, cannot download bzip2 Jaime Wyant Python 0 04-21-2005 12:49 PM
RE: (Python newbie) Using XP-SP2/MSVC6: No Python24_d.lib,winzip barfs on Python-2.4.1.tar, cannot download bzip2 Bill Davy Python 0 04-19-2005 09:27 AM
BZip2-Files & Java Christian Decker Java 9 02-20-2005 05:44 PM



Advertisments