Results 1 to 6 of 6
  1. #1
    Mohang is offline Member
    Join Date
    Nov 2013
    Posts
    1
    Rep Power
    0

    Default Password protection for zip file

    Dear all,

    We are using the below code to zip the input file


    Java Code:
    import java.util.zip.*;
    import java.io.*;
    public class UTLZip
    {
    public static void  COMPRESSFILE(String infilename, String outfilename)throws Exception{
    try{
       FileInputStream fin = new FileInputStream(infilename);
       FileOutputStream fout = new FileOutputStream(outfilename);
       ZipOutputStream zout = new ZipOutputStream(fout);
       ZipEntry ze = new ZipEntry((new File(infilename)).getName());
       zout.putNextEntry(ze);
       copy(fin, zout);
       zout.closeEntry();
       fin.close();
       zout.close();
      }catch(Exception e){
    	  System.out.println("IO Exception occurred: " + e);
    
      }
    }
    public static void copy(InputStream in, OutputStream out)throws Exception{ 
    byte[] buffer = new byte[4096];
    while (true) {
      int bytesRead = in.read(buffer);
      if (bytesRead == -1) break;
      out.write(buffer, 0, bytesRead);
    }
    }
    public static void main(String arg[]){}    
    };
    now the requirement is to protect the file with password given,

    how to achieve this, above code has been developed by my company's old employee, am not familiar with java
    kindly help me to achieve this,

    Thanks,
    Mohan

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,050
    Rep Power
    6

    Default Re: Password protection for zip file

    as far as I know you can't do it with the standard API. You'll need to hire someone that actually does know Java, this is not a free coding service.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    ArnavKumar is offline Member
    Join Date
    Oct 2013
    Posts
    11
    Rep Power
    0

    Default Re: Password protection for zip file

    Remove ';' from the last line
    Last edited by Tolls; 11-07-2013 at 04:42 PM.

  4. #4
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,656
    Rep Power
    5

    Default Re: Password protection for zip file

    A quick search of the web provided some third party API's which may help. Have you tried that?

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,050
    Rep Power
    6

    Default Re: Password protection for zip file

    Quote Originally Posted by jim829 View Post
    Have you tried that?
    I quote:

    am not familiar with java
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,656
    Rep Power
    5

    Default Re: Password protection for zip file

    Ah! I glossed over that part.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Replies: 0
    Last Post: 10-29-2013, 03:26 AM
  2. Replies: 17
    Last Post: 05-22-2012, 01:19 PM
  3. how to check password for 3 times enterd wrong password
    By sk.mahaboobbhasha@gmail.c in forum New To Java
    Replies: 2
    Last Post: 11-14-2008, 07:53 PM
  4. how to check password for 3 times enterd wrong password
    By sk.mahaboobbhasha@gmail.c in forum Java Servlet
    Replies: 0
    Last Post: 11-14-2008, 01:22 PM
  5. How to check password of a jsp/html with the password of Database(mysql) #1
    By sk.mahaboobbhasha@gmail.c in forum Java Servlet
    Replies: 2
    Last Post: 11-14-2008, 01:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •