Name: zl72593 Date: 11/23/98
=20
package JTh;
import java.io.*;
import java.awt.*;
import java.util.zip.*;
public class fullFile implements Serializable {
=09File OrgName;
=09fullFile() {};
=09fullFile(String namestring)
=09{
=09=09OrgName =3D new File(namestring);
=09}
=09private void writeObject(java.io.ObjectOutputStream out)=20
=09=09=09throws IOException
=09{
=09=09byte[] b =3D new byte[64*512], cb =3D new byte[64*512];
=09=09Deflater df =3D new Deflater(Deflater.BEST_SPEED);
=09=09int len, clen, i;
=09=09out.defaultWriteObject();
=09=09BufferedInputStream FI =3D new BufferedInputStream(new FileInputStrea=
m(OrgName), 64*512);=20
=09=09len =3D FI.read(b);
=09=09while (len !=3D -1) {
=09=09=09df.setInput(b, 0, len);
=09=09=09do {
=09=09=09=09clen =3D df.deflate(cb);
=09=09=09=09out.writeInt(clen);
=09=09=09=09out.write(cb, 0, clen);
=09=09=09} while (!df.needsInput());
=09=09=09len =3D FI.read(b);=20
=09=09}
=09=09df.finish();
=09=09do {
=09=09=09clen =3D df.deflate(cb);
=09=09=09if (clen > 0) {
=09=09=09=09out.writeInt(clen);
=09=09=09=09out.write(cb, 0, clen);
=09=09=09}
=09=09} while (!df.finished());
=09=09out.writeInt(len);
=09=09out.writeInt(df.getAdler());
=09=09out.flush();
=09=09System.out.println("Total "+df.getAdler()+" "+df.getTotalIn()+" "+df.=
getTotalOut());
=09}
=09private void readObject(java.io.ObjectInputStream in)=20
=09=09=09throws IOException, ClassNotFoundException=20
=09{
=09=09byte[] b =3D new byte[64*512], cb =3D new byte[64*512];
=09=09Inflater inf =3D new Inflater();
=09=09int len, fejl =3D 0;
=09=09in.defaultReadObject();
=09=09OrgName =3D new File(OrgName.getName());
=09=09FileDialog fd =3D new FileDialog(new Frame(), "Gem fil", FileDialog.S=
AVE);
=09=09fd.setFile(OrgName.getName());
=09fd.show();
=09=09String navn =3D fd.getDirectory()+fd.getFile();
=09=09OrgName =3D new File(navn);
=09=09BufferedOutputStream FO =3D new BufferedOutputStream(new FileOutputSt=
ream(navn), 64*512);=20
=09=09len =3D in.readInt();
=09=09while (len !=3D -1)
=09=09{int l =3D 0, j;
=09=09=09do {
=09=09=09=09j =3D in.read(cb, l, len - l);
=09=09=09=09l =3D l + j;
=09=09=09} while (l <len);
=09=09=09inf.setInput(cb,0,len);
=09=09=09do {
=09=09=09=09try {l =3D inf.inflate(b);}=20
=09=09=09=09catch (DataFormatException e) {fejl =3D 1;}=20
=09=09=09=09FO.write(b, 0, l);
=09=09=09} while (!inf.needsInput());=20
=09=09=09len =3D in.readInt();
=09=09}=20
=09=09FO.flush(); FO.close();
=09=09int orgad =3D in.readInt();=20
=09=09int ad =3D inf.getAdler();
=09=09if (orgad !=3D ad && fejl =3D=3D 0) fejl =3D 2;
=09=09if (fejl> 0) System.out.println("Fejl nr. "+fejl);
=09=09System.out.println("Total "+orgad+" "+ad+" "+inf.getTotalIn()+" "+inf=
.getTotalOut());
=09}
}
(Review ID: 42176)
======================================================================
###@###.### 2004-09-16
=20
package JTh;
import java.io.*;
import java.awt.*;
import java.util.zip.*;
public class fullFile implements Serializable {
=09File OrgName;
=09fullFile() {};
=09fullFile(String namestring)
=09{
=09=09OrgName =3D new File(namestring);
=09}
=09private void writeObject(java.io.ObjectOutputStream out)=20
=09=09=09throws IOException
=09{
=09=09byte[] b =3D new byte[64*512], cb =3D new byte[64*512];
=09=09Deflater df =3D new Deflater(Deflater.BEST_SPEED);
=09=09int len, clen, i;
=09=09out.defaultWriteObject();
=09=09BufferedInputStream FI =3D new BufferedInputStream(new FileInputStrea=
m(OrgName), 64*512);=20
=09=09len =3D FI.read(b);
=09=09while (len !=3D -1) {
=09=09=09df.setInput(b, 0, len);
=09=09=09do {
=09=09=09=09clen =3D df.deflate(cb);
=09=09=09=09out.writeInt(clen);
=09=09=09=09out.write(cb, 0, clen);
=09=09=09} while (!df.needsInput());
=09=09=09len =3D FI.read(b);=20
=09=09}
=09=09df.finish();
=09=09do {
=09=09=09clen =3D df.deflate(cb);
=09=09=09if (clen > 0) {
=09=09=09=09out.writeInt(clen);
=09=09=09=09out.write(cb, 0, clen);
=09=09=09}
=09=09} while (!df.finished());
=09=09out.writeInt(len);
=09=09out.writeInt(df.getAdler());
=09=09out.flush();
=09=09System.out.println("Total "+df.getAdler()+" "+df.getTotalIn()+" "+df.=
getTotalOut());
=09}
=09private void readObject(java.io.ObjectInputStream in)=20
=09=09=09throws IOException, ClassNotFoundException=20
=09{
=09=09byte[] b =3D new byte[64*512], cb =3D new byte[64*512];
=09=09Inflater inf =3D new Inflater();
=09=09int len, fejl =3D 0;
=09=09in.defaultReadObject();
=09=09OrgName =3D new File(OrgName.getName());
=09=09FileDialog fd =3D new FileDialog(new Frame(), "Gem fil", FileDialog.S=
AVE);
=09=09fd.setFile(OrgName.getName());
=09fd.show();
=09=09String navn =3D fd.getDirectory()+fd.getFile();
=09=09OrgName =3D new File(navn);
=09=09BufferedOutputStream FO =3D new BufferedOutputStream(new FileOutputSt=
ream(navn), 64*512);=20
=09=09len =3D in.readInt();
=09=09while (len !=3D -1)
=09=09{int l =3D 0, j;
=09=09=09do {
=09=09=09=09j =3D in.read(cb, l, len - l);
=09=09=09=09l =3D l + j;
=09=09=09} while (l <len);
=09=09=09inf.setInput(cb,0,len);
=09=09=09do {
=09=09=09=09try {l =3D inf.inflate(b);}=20
=09=09=09=09catch (DataFormatException e) {fejl =3D 1;}=20
=09=09=09=09FO.write(b, 0, l);
=09=09=09} while (!inf.needsInput());=20
=09=09=09len =3D in.readInt();
=09=09}=20
=09=09FO.flush(); FO.close();
=09=09int orgad =3D in.readInt();=20
=09=09int ad =3D inf.getAdler();
=09=09if (orgad !=3D ad && fejl =3D=3D 0) fejl =3D 2;
=09=09if (fejl> 0) System.out.println("Fejl nr. "+fejl);
=09=09System.out.println("Total "+orgad+" "+ad+" "+inf.getTotalIn()+" "+inf=
.getTotalOut());
=09}
}
(Review ID: 42176)
======================================================================
###@###.### 2004-09-16
- duplicates
-
JDK-4311493 ADLER-32 does not work in java.util.zip.Inflater
- Closed
- relates to
-
JDK-4403505 Inflater.finished() never returns true with Netscape or HotJava
- Closed