ByteArrayInputStream bais = new ByteArrayInputStream( bytes ); // in
InflaterInputStream iis = new InflaterInputStream( bais ); // wrap in
Should I be using InflaterInputStream or ZipInputStream? Are their setting
in the stream dictionary that are needed for decoding? Like, what does the
"/S 36" mean in the following object? I've been looking in the PDF
Reference Guide, but I haven't had any luck.
14 0 obj
<< /S 36 /Filter /FlateDecode /Length 15 0 R >>
stream
H?b``ŕb``ęc...
endstream
endobj
Here are the errors I'm receiving:
java.util.zip.ZipException: incomplete dynamic bit lengths tree
java.util.zip.ZipException: invalid distance code
java.util.zip.ZipException: invalid bit length repeat
Anyone know why I might be getting errors like these errors? Any help
decoding flate streams in Java would be greately appreciated.
Thanks,
Cameron
> I am trying to decompress (inflate) a flate compressed stream using the
> Java
> 2 SDK SE v1.4. Although flate compression is built in to Java, I am
> having
> some major issues. I'm using the the following couple of classes:
>
> ByteArrayInputStream bais = new ByteArrayInputStream( bytes ); // in
> InflaterInputStream iis = new InflaterInputStream( bais ); // wrap in
>
> Should I be using InflaterInputStream or ZipInputStream? Are their
> setting
> in the stream dictionary that are needed for decoding? Like, what does
> the
> "/S 36" mean in the following object? I've been looking in the PDF
> Reference Guide, but I haven't had any luck.
>
> 14 0 obj
> << /S 36 /Filter /FlateDecode /Length 15 0 R >>
> stream
> H?b``àb``êc...
> endstream
> endobj
>
> Here are the errors I'm receiving:
>
> java.util.zip.ZipException: incomplete dynamic bit lengths tree
> java.util.zip.ZipException: invalid distance code
> java.util.zip.ZipException: invalid bit length repeat
>
> Anyone know why I might be getting errors like these errors? Any help
> decoding flate streams in Java would be greately appreciated.
>
> Thanks,
> Cameron
You can use the FlateDecoder built into Adobe's discontinued bean....
MArk
nate
ma...@idrsolutions.com wrote in message news:<abeden$t7g$1...@knossos.btinternet.com>...
> Cameron Taggart wrote:
>
> > I am trying to decompress (inflate) a flate compressed stream using the
> > Java
> > 2 SDK SE v1.4. Although flate compression is built in to Java, I am
> > having
> > some major issues. I'm using the the following couple of classes:
> >
> > ByteArrayInputStream bais = new ByteArrayInputStream( bytes ); // in
> > InflaterInputStream iis = new InflaterInputStream( bais ); // wrap in
> >
> > Should I be using InflaterInputStream or ZipInputStream? Are their
> > setting
> > in the stream dictionary that are needed for decoding? Like, what does
> > the
> > "/S 36" mean in the following object? I've been looking in the PDF
> > Reference Guide, but I haven't had any luck.
> >
> > 14 0 obj
> > << /S 36 /Filter /FlateDecode /Length 15 0 R >>
> > stream
> > H?b``ŕb``ęc...
>> > H?b``àb``êc...
>> > endstream
>> > endobj
>> >
>> > Here are the errors I'm receiving:
>> >
>> > java.util.zip.ZipException: incomplete dynamic bit lengths tree
>> > java.util.zip.ZipException: invalid distance code
>> > java.util.zip.ZipException: invalid bit length repeat
>> >
>> > Anyone know why I might be getting errors like these errors? Any help
>> > decoding flate streams in Java would be greately appreciated.
>> >
>> > Thanks,
>> > Cameron
>>
>> You can use the FlateDecoder built into Adobe's discontinued bean....
>>
>> MArk
Here's my code.
MArk
//////////////////////////////////////////////////
/**
* flate decode using adobes class
*/
private byte[] flateDecode(byte[] data,String filter_list,String
decode_params){
Object key;
Object value;
byte[] processed_data=null;
Integer Predictor=new Integer(1);
Integer Colors=new Integer(1);
Integer BitsPerComponent=new Integer(8);
Integer Columns=new Integer(1);
Integer EarlyChange=new Integer(1);
try{
//put params in object
FilterParams params=new FilterParams();
//reset vales
StringTokenizer values=new StringTokenizer(decode_params,"< >");
while(values.hasMoreTokens()){
key=values.nextToken();
String test=key.toString();
if(test.startsWith("/")){
value=values.nextElement();
//set values
if(test.equals("/Predictor"))
Predictor=new Integer(value.toString());
if(test.equals("/Colors"))
Colors=new Integer(value.toString());
if(test.equals("/BitsPerComponent"))
BitsPerComponent=new Integer(value.toString());
if(test.equals("/Columns"))
Columns=new Integer(value.toString());
if(test.equals("/EarlyChange"))
EarlyChange=new Integer(value.toString());
}
}
params.put("Predictor",Predictor);
params.put("Colors",Colors);
params.put("BitsPerComponent",BitsPerComponent);
params.put("Columns",Columns);
params.put("EarlyChange",EarlyChange);
FlateInputStream flate_filter=
new FlateInputStream(new BufferedInputStream(new
ByteArrayInputStream(data)),params);
ByteArrayOutputStream out=new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int bytes_read;
//loop to write the data
while((bytes_read =flate_filter.read(buffer))!=-1){
out.write(buffer,0,bytes_read);
}
//close and get the data
flate_filter.close();
out.close();
processed_data=out.toByteArray();
}catch(Exception e){
LogWriter.writeLog("Exception "+e+" accessing flate filter");
}
return processed_data;
}
Cameron
<ma...@idrsolutions.com> wrote in message
news:abqsv9$mh9$1...@helle.btinternet.com...
> >> > H?b``ŕb``ęc...