@@ -0,0 +1,1929 @@
+package au.gov.amsa.geo.adhoc;%0A%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.zip.ZipEntry;%0Aimport java.util.zip.ZipOutputStream;%0A%0Apublic class ZipShapefilesMain %7B%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        File directory = new File(%22/home/dave/Downloads/port_area_shapefiles%22);%0A        String%5B%5D list = directory.list();%0A        Arrays.sort(list);%0A        String lastKey = null;%0A        List%3CFile%3E files = new ArrayList%3C%3E();%0A        for (int i = 0; i %3C list.length; i++) %7B%0A            String name = list%5Bi%5D;%0A%0A            String key = name.substring(4, name.indexOf(%22_port_pl.%22));%0A            // System.out.println(key);%0A            if (lastKey != null && !key.equals(lastKey)) %7B%0A                zip(lastKey, files);%0A                files.clear();%0A            %7D%0A            files.add(new File(directory, name));%0A            lastKey = key;%0A        %7D%0A        zip(lastKey, files);%0A    %7D%0A%0A    private static void zip(String key, List%3CFile%3E files) throws IOException %7B%0A        System.out.println(key);%0A        for (File file : files) %7B%0A            System.out.println(%22    %22 + file);%0A        %7D%0A        File out = new File(%22target/%22 + key + %22_visit_pl.zip%22);%0A        try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(out))) %7B%0A            for (File file : files) %7B%0A                byte%5B%5D buffer = new byte%5B8192%5D;%0A                ZipEntry ze = new ZipEntry(file.getName());%0A                zos.putNextEntry(ze);%0A                try (FileInputStream fis = new FileInputStream(file)) %7B%0A                    int len;%0A                    while ((len = fis.read(buffer)) %3E 0) %7B%0A                        zos.write(buffer, 0, len);%0A                    %7D%0A                %7D%0A                zos.closeEntry();%0A            %7D%0A        %7D%0A    %7D%0A%0A%7D%0A

add ZipShapefilesMain for zipping groups of shapefile files