java.io.zip.Deflater.df.getAdler() always return -1 ...
import java.io.*;
import java.util.*;
import java.util.zip.*;
// __
class UnzipWithChecksum02{
ArrayList<Long> ALL;
// __
UnzipWithChecksum02(){ ALL = new ArrayList<Long>(); }
// __
public Long[] unzip(String[] aIFls){
Long[] LAdler32Ar = null;
// __
int iRdByts, iBfrSz = 2048;
byte[] buffer = new byte[iBfrSz];
ZipEntry ZEnt;
CheckedInputStream ChkSum = null;
long lAdler32;
Long LAdler32;
// __
if((aIFls != null) && (aIFls.length > 0)){
for(int i = 0; (i < aIFls.length); ++i){
LAdler32 = null;
ZipInputStream ZIS = null;
// __
try{
File IFl = new File(aIFls[i]);
// __ Creating input stream that also maintains the ChkSum of the data which later can be used to validate data integrity.
ChkSum = new CheckedInputStream(new FileInputStream(IFl), new Adler32());
ZIS = new ZipInputStream(new BufferedInputStream(ChkSum));
// __
while((ZEnt = ZIS.getNextEntry()) != null){
while(ZIS.read() != -1);
}
ZIS.close();
// __
lAdler32 = ChkSum.getChecksum().getValue();
System.err.println("// __ lAdler32: |" + lAdler32 + "|");
LAdler32 = new Long(lAdler32);
// __
}catch(FileNotFoundException FNFX){ FNFX.printStackTrace(System.err); }
catch(IOException IOX){ IOX.printStackTrace(System.err); }
// __
finally {
if(ZIS != null){ try{ ZIS.close(); }catch(IOException IOX){ ; } }
}
// __
ALL.add(LAdler32);
}// i: [0, )
// __
if(ALL.size() > 0){ LAdler32Ar = new Long[ALL.size()]; ALL.toArray(LAdler32Ar); }
}// ((aIFls != null) && (aIFls.length > 0))
// __
return(LAdler32Ar);
}
}