Solved

"Invalid Block Type" exception message

Posted on 2006-11-16
9
745 Views
Last Modified: 2008-03-17
I got "Invalid Block Type" exception message in my program. I'm not sure what this is. Could somebody please advice?

The code is actually fine when I run it in my local machine (windows).
It retrieves the data just fine.
But when I run it in the server (linux), it gives me this exception.

Thanks.

-----------------------------------------------------------------------------------------------------

GZIPInputStream gzip_in_stream = null;
BufferedOutputStream destination_out_stream = new BufferedOutputStream(
   new FileOutputStream(weatherFile), BUF_SIZE);
   byte[] input_buffer = new byte[BUF_SIZE];
int byteLength = 0;            
 
InputStream tempStream = ftpClient.retrieveFileStream(zippedFile);
                  
gzip_in_stream = new GZIPInputStream(
new BufferedInputStream(tempStream));

while ( (byteLength = gzip_in_stream.read(input_buffer, 0, BUF_SIZE)) > 0 )
{
destination_out_stream.write(input_buffer, 0, byteLength);      
}
 
destination_out_stream.flush(); // Ensure all the data is written to the output.
destination_out_stream.close();
gzip_in_stream.close();      

0
Comment
Question by:rnicholus
  • 5
  • 4
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Try

while ( (byteLength = gzip_in_stream.read(input_buffer, 0, BUF_SIZE)) > -1 )
0
 

Author Comment

by:rnicholus
Comment Utility
It gives me:

"incomplete dynamic bit lengths tree"
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 300 total points
Comment Utility
Make sure the file is not corrupt by running zcat or something against it
0
 

Author Comment

by:rnicholus
Comment Utility
I do "zcat [filename]" and then it prints the contents of the file in the console and it doesn't give me any warning or error.
I've never used zcat before. Is this what supposed to happen?

Thanks
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Yep. I think you can safely take it that the file's not corrupt from that. No further ideas at the moment although you might check that this is not a known bug
0
 

Author Comment

by:rnicholus
Comment Utility
Now it gives me "corrupt gzip trailer" on these lines below.

------------------------------
while ( (byteLength = gzip_in_stream.read(input_buffer, 0, BUF_SIZE)) > 0 )
{System.out.println("** test **");
destination_out_stream.write(input_buffer, 0, byteLength);      
}
------------------------------

It seems that it goes inside the while loop printing the String "** test **" before it gives me the error message "corrupt gzip trailer".
0
 

Author Comment

by:rnicholus
Comment Utility
I've also tried using ">-1" instead of ">0".

Also I've tried using zcat again.
0
 

Author Comment

by:rnicholus
Comment Utility
Doing these below seem to solve the problem:

ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);

I will give points for CEHJ for the assistance in finding the answer.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:-)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now