Home Java Java-conversion Convert Zip To EXE
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Convert Zip To EXE

Advertisement
In this example we are going to convert a zipped file into exe.

Convert Zip To EXE

     

In this example we are going to convert a zipped file into exe.

To convert a Zip file into .exe file pass the name of a zip file using command line arguments. Use FileInputStream  to take the zipped file as input. Read the file from the system, unzip the file and store the data of this file into a byte array. Create another file with .exe extension. Write the byte formatted data of the unzip file into .exe file.  

Create FileOutputStream object pass the name of file with .exe extension for creating an exe file. ZipInputStream allows modification on zipped (or unzipped) file. Use getNextEntry() method to set the entry point of the zip file. Create an array of bytes which stores the data of unzipped file and finally write the data into exe file.

Here is the code of the program :

import java.io.*;
import java.awt.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import java.io.*;
import java.util.zip.*;
public class  ZipToEXE

public static void main(String arg[])throws Exception
  {  
  OutputStream out=new FileOutputStream
(
"pdfFile.exe");
  ZipInputStream  zip = new ZipInputStream
(
new BufferedInputStream(new FileInputStream(arg[0])));
  ZipEntry entry;
  while((entry = zip.getNextEntry()) != null)
  {
  byte data[]=new byte[1024];
  int count;
  while((count=zip.read(data,0,1024))!=-1)
  {
  out.write(data,0,count);
  
  
  out.flush();
  out.close();
  }
}

Download this example.

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 14, 2008

Ask Questions?    Discuss: Convert Zip To EXE  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
pandiyan
April 25, 2011
convert

sorry sir, wich converter? type: software file to convert a exe or aplication file. i have gone to the website, but no discurtion/ also haven't problem solve. so this website asking to you, please help me.
mohamednizar
September 6, 2011
nokia application

file name .zip file nokia zip file could not install mobile phone how can install
c.saravanan
September 20, 2011
convert zip into .exe

trying
Bala
October 21, 2011
download

super
Binod Samantaray
April 19, 2012
zip folder convert to excel

pl. change this file
yogesh
December 29, 2012
zip to exe games

my question is my pc is one game zip file this game not running in pc show in error is cannot excute exe how to solve this programe
Java Guy
November 12, 2012
this has no chance of ever working

This simply creates a zip file and names it "pdfFile.exe". There is no attempt to make it a valid EXE file. Very silly.
DMCA.com