dcsimg
Compressed Input and Output Streams
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, August 13, 2001 12:39 PM

How can I create an RMI server that implements data compression?


Specifically any hints on creating Compressed I/O streams using built in Compression Streams like DeflaterOutputStream and InflaterInputStream or their sub classes are appreciated.

Re: Compressed Input and Output Streams

Posted By:   Rajesh_Khanna  
Posted On:   Thursday, October 21, 2004 05:32 AM

may be this program may help you to convert a file into a zip file
import java.io.*;

import java.util.zip.*;

class filewriter

{
FileInputStream fis;

FileOutputStream fos;

ZipOutputStream zos;

ZipInputStream zis;

ZipEntry e,e1;

byte b[];

String text="";

public filewriter()

{
try


{
zis=new ZipInputStream(new FileInputStream("d:/pop/file.zip"));


e=zis.getNextEntry();

int j=0;

while((j=zis.read())!=-1)


{
text+=(char)j;


}
e=zis.getNextEntry();


while((j=zis.read())!=-1)


{
text+=(char)j;


}
System.out.println(text);



System.out.println(text);


fis=new FileInputStream("d:/pop/jms.txt");


zos=new ZipOutputStream(new FileOutputStream("d:/pop/file.zip"));


e1=new ZipEntry("d:/pop/jms.txt");


e1.setMethod(ZipEntry.DEFLATED);


zos.putNextEntry(e1);


String str="";


int i=0;


while((i=fis.read())!=-1)


{
str+=(char)i;


}
zos.write(str.getBytes());


zos.putNextEntry(e);


zos.write(text.getBytes());


zos.closeEntry();





}catch(Exception e)


{
e.printStackTrace();
}
}
}
public class zipfile


{
public static void main(String ar[])


{
new filewriter();


}
}
About | Sitemap | Contact