public void packFiles(String path) throws IOException, NullPointerException { GregorianCalendar gc = new GregorianCalendar(); //heute SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); if (path == null) { throw new NullPointerException("path = null"); } File f = new File(path); if (!f.exists()) { throw new IOException("path ist nicht vorhanden"); } if (f.isFile()) { f = f.getParentFile(); //Verzeichnis davon } File[] af = f.listFiles(); FileInputStream in; int iL; byte[] ab; ZipEntry zipFile; ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(new File(f, format.format(gc.getTime()) + "log.zip"))); zipOut.setLevel(9); //stark komprimiert for (int i = 0; i < af.length; i++) { if (af.isFile() && af.getName().endsWith(".log")) { zipFile = new ZipEntry(af.getName()); in = new FileInputStream(af); ab = new byte[1024]; zipOut.putNextEntry(zipFile); while ((iL = in.read(ab)) > -1) { zipOut.write(ab, 0, iL); } zipOut.closeEntry(); in.close(); af.delete(); //gepackt, also löschen } } zipOut.close();}