Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BZip2-Files & Java

3 views
Skip to first unread message

Christian Decker

unread,
Feb 2, 2005, 11:03:52 AM2/2/05
to
Ok two things:
I'm trying to get the Apache BZip2 Library to work, but I always get a
NullPointerException. My code looks like this:

[CODE]
void load(String filename) throws FileNotFoundException, IOException {
FileInputStream fis = new FileInputStream(filename);
CBZip2InputStream = new CBZip2InputStream(fis);
}
[/CODE]

As soon as the creation of the CBZip2InputStream is reached, a
NullpointerException is thrown. Why?
Secondly: if the library is corrupted (e.g. doesn't work stable) is
there an alternative to it (Googleing did not help me very much)?

Snyke

Andrey Kuznetsov

unread,
Feb 2, 2005, 1:14:02 PM2/2/05
to
> As soon as the creation of the CBZip2InputStream is reached, a
> NullpointerException is thrown. Why?
post stack trace first

--
Andrey Kuznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities


Snyke

unread,
Feb 3, 2005, 7:35:09 PM2/3/05
to
java.io.FileNotFoundException: PublicHubList.config.bz2 (No such file
or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at HubList.load(HubList.java:17)
at HubList.<init>(HubList.java:28)
at BlackPhoenix.main(BlackPhoenix.java:17)

Whereas HubList and BlackPhoenix my own classes are.

Andrey Kuznetsov

unread,
Feb 4, 2005, 6:19:18 AM2/4/05
to
... and PublicHubList.config.bz2 is file you want to decompress...
FileNotFoundException means that file was not found (deep thought :)
Hint: may be file name was wrong?

Snyke

unread,
Feb 4, 2005, 8:35:45 AM2/4/05
to
Ah sorry, I moved PublicHubList.config.bz2 to another location so this
is the obvious error: I was looking for this one:

Exception in thread "main" java.lang.NullPointerException
at
org.apache.tools.bzip2.CBZip2InputStream.bsR(CBZip2InputStream.java:323)
at
org.apache.tools.bzip2.CBZip2InputStream.bsGetUChar(CBZip2InputStream.java:341)
at
org.apache.tools.bzip2.CBZip2InputStream.initBlock(CBZip2InputStream.java:230)
at
org.apache.tools.bzip2.CBZip2InputStream.<init>(CBZip2InputStream.java:178)
at HubList.load(HubList.java:19)

Andrey Kuznetsov

unread,
Feb 6, 2005, 5:47:14 AM2/6/05
to
> Exception in thread "main" java.lang.NullPointerException
> at
> org.apache.tools.bzip2.CBZip2InputStream.bsR(CBZip2InputStream.java:323)
> at
> org.apache.tools.bzip2.CBZip2InputStream.bsGetUChar(CBZip2InputStream.java:341)
> at
> org.apache.tools.bzip2.CBZip2InputStream.initBlock(CBZip2InputStream.java:230)
> at
> org.apache.tools.bzip2.CBZip2InputStream.<init>(CBZip2InputStream.java:178)
> at HubList.load(HubList.java:19)
> at HubList.<init>(HubList.java:28)
> at BlackPhoenix.main(BlackPhoenix.java:17)

InputStream that you pass to CBZip2InputStream' constructor is null.
Check your code.

Snyke

unread,
Feb 6, 2005, 10:26:45 AM2/6/05
to
The debugger sais that fis is actually initialized.

Andrey Kuznetsov

unread,
Feb 6, 2005, 6:34:01 PM2/6/05
to
> The debugger sais that fis is actually initialized.
>
hmm, may be we have different source...

I have in CBZip2InputStream.java at line 323 following:
"thech = (char) bsStream.read();"
NullPointerException can only be here if bsStream is null.

Why don't you put a breakpoint in CBZip2InputStream.java at line 323 and
looks what's wrong?

Snyke

unread,
Feb 7, 2005, 12:16:47 PM2/7/05
to
bStream is null but I don't get it: the InputStream I used to create
the CBZip2InputStream with is not null and is not null when the
Exception is thrown.

Melih Cetin via JavaKB.com

unread,
Feb 20, 2005, 12:44:58 PM2/20/05
to
I had a similar problem due to the leading "BZ" stream identifiers in the
input file. When I removed these two characters from the input stream
before providing it to CBZip2InputStream constructor, the problem has been
sorted out. You may want to refer to http://www.kohsuke.org/bzip2/ for a
mention of this problem.

I hope this helps.

--
Message posted via http://www.javakb.com

0 new messages