You can use java.io.File for either files or directories. So you can create the source directory like so:
File sourceDir = new File("C:\\test");
and then get all the subdirectories or files as an array of files:
File subdirects = sourceDir.listFiles();
Then you can simply test each subdirectory to see if it is a directory or file.
The best way to manipulate a batch of directories and files is to use a recursive process, as in the method zipFiles shown below.
So you can call zipFiles, passing in sourceDir = new File("C:\\test");
BufferedInputStream origin = null; FileOutputStream dest = new FileOutputStream("c:\\MyZip1.zip"); CheckedOutputStream checksum = new CheckedOutputStream(dest, new Adler32()); ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(checksum)); //out.setMethod(ZipOutputStream.DEFLATED); byte data = new byte[BUFFER];