Powered by Blogger.

7). Program to Zipping the contents present with in the file.

>> Tuesday, May 3, 2011

Making a file into unreadable format.

To Zip the contents present with in a file the class DeflatorOutputStream is used.This class is defined with in the util package.

DeflaterOutputStream dos = new DeflaterOutputStream(fos);

The Object of DeflatorOutputStream class will expect FileOutputStream object as an argument.


package javabynataraj.iopack;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.DeflaterOutputStream;

public class UnreadableFile {
    public static void main(String[] args)throws IOException {
        FileInputStream fis = new FileInputStream("hello2.dat");
        FileOutputStream fos = new FileOutputStream("zip_hello");
        DeflaterOutputStream dos = new DeflaterOutputStream(fos);
        int ch;
        while((ch = fis.read())!= -1){

Related Posts Plugin for WordPress, Blogger...
© javabynataraj.blogspot.com from 2009 - 2014. All rights reserved.