Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Password Protection in ZIP File

sanJul 4 2012 — edited Dec 7 2012
Hello All,

i Have referred some code to create a zip file. Its working fine. Now i want to add the password protection in that zip file. Can anyone help me out to achieve this???

zip code:
------------
import java.util.zip.*;
import java.io.*;
public class UTLZip
{
 public static void compressFile(String infilename, String outfilename)
 throws IOException
 {
  try
    {
     FileOutputStream fout = new FileOutputStream(outfilename);
     ZipOutputStream zout = new ZipOutputStream(fout);
     ZipEntry ze = new ZipEntry((new File(infilename)).getName());
     try 
       {
        FileInputStream fin = new FileInputStream(infilename);
        zout.putNextEntry(ze);
        copy(fin, zout);
        zout.closeEntry();
        fin.close();
       }
     catch (IOException ie)
     {
      System.out.println("IO Exception occurred: " + ie);
     }
     zout.close();
    }
  catch(Exception e)
    {
     System.out.println("Exception occurred: " + e);
    }
 }
  
 public static void copy(InputStream in, OutputStream out) 
      throws IOException
 { 
  byte[] buffer = new byte[4096];
  while (true) {
    int bytesRead = in.read(buffer);
    if (bytesRead == -1) break;
    out.write(buffer, 0, bytesRead);
  }
 }     
}
 
----------------------------------------------------------------

create or replace
PACKAGE               "SSSL_FILE_ZIP" 
IS
   PROCEDURE compressFile (p_in_file IN VARCHAR2, p_out_file IN VARCHAR2)
   AS
      LANGUAGE JAVA
         NAME 'UTLZip.compressFile(java.lang.String,
                   java.lang.String)';
END;

 
 
Thanks in Advance
San,
This post has been answered by Anton Scheffer on Dec 7 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 4 2013
Added on Jul 4 2012
15 comments
13,197 views