Issue in Converting .zip file to .jar file?

Ads
 

Issue in Converting .zip file to .jar file?

I have a folder called "printpdf.jar". I have changed the .jar to .zip and did some customizations. After which i had "zipped" it again and made as ".jar". Now the final file is displayed in executable icon rather then text editor icon. How do i make it display in text editor icon.

View Answers

April 19, 2011 at 4:55 PM

import java.io.*;
import java.util.*;
import java.util.jar.*;
import java.util.zip.*;

public class ConvertZipToJar{
public static void main(String[]args)throws Exception{
byte b[] = new byte[10240];
FileOutputStream fout = new FileOutputStream(new File("C:/TextExamples.jar"));
JarOutputStream out = new JarOutputStream(fout, new Manifest());
ZipFile zf = new ZipFile("C:/TextExamples.zip");
Enumeration entries = zf.entries();
while(entries.hasMoreElements()){
ZipEntry ze = (ZipEntry) entries.nextElement();
System.out.println("Adding " + ze.getName());
JarEntry addFiles = new JarEntry(ze.getName());
out.putNextEntry(addFiles);
      long size = ze.getSize();
          if (size > 0){
            System.out.println("Length is " + size);
            BufferedReader br = new BufferedReader(new InputStreamReader(zf.getInputStream(ze))); 
            String line;
            while((line = br.readLine()) != null) {
              System.out.println(line);
              out.write(line.getBytes());
            }
             br.close();
          }
}
out.close();
fout.close();
}
}

Ads









Related Tutorials/Questions & Answers:
Issue in Converting .zip file to .jar file?
Converting Text Files into Bzip File
Advertisements
find jar file name from multiple set of jar files
Java JAR Files
JAR FILE
How to use JAR file in Java
jar file - Java Beginners
quqtion on jar files
jar file
jar file
jar file
sending a zip file to servlet
Java Jar File
Structs jar files
ModuleNotFoundError: No module named 'zip-files'
executing a batch file which depends on jar files from a system tray but console should not display.
jar file
Java Zip Package
File path for jar file
How to convert multiple files in java to .zip format
Java Util Zip. Zip files/folders inside a folder, without zipping the original source folder.
Apache HSSF Jar file location
Running Jar file in Windows
How to Unjar a Jar file in Java
ffmpeg converting file mp4 to mov
converting one file format to another
How to zip a file using javascrip?
convert zip file to byte array
converting an xml file in relational database objects
Extract Jar File
How to create a jar file

Ads