• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Install java files

Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys
I got small problem on Installation..
How can i install all my class java files with one file i mean either Zip or Jar using java program..

I have 100 class files there .So what i want these 100 java class files into one zip file.
Actaully i wrote one java program with one java file.But i need more that 100 files.If any body know pls inform me .
I given my program working with only one java file.
import java.io.*;
public class zip {
public static void main(String j[]) {
try {
String inFilename = "connect.java";
String outFilename = "k2mail.zip"
FileInputStream in = new FileInputStream(inFilename);
java.util.zip.ZipOutputStream out = new java.util.zip.ZipOutputStream(new FileOutputStream(outFilename));

// Add ZIP entry to output stream.
out.putNextEntry(new java.util.zip.ZipEntry(inFilename));

byte[] buf = new byte[1024];
int len;

while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);

} catch (IOException e) {
So i need more that 100 files..
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure but do you want to read all the file in the directory instead of specifying them
individually in your java program? For that you can create a File Object and use File.list() to
get all the files in that directory. You can keep a loop which will create ZipEntry for all the
files and call putNextEntry to add in
[ July 01, 2002: Message edited by: Snigdha Solanki ]
And then we all jump out and yell "surprise! we got you this tiny ad!"
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic