Here you can find the source of zipDirectoryEntry(ZipOutputStream output, IPath entry, long time, Set
private static void zipDirectoryEntry(ZipOutputStream output, IPath entry, long time, Set<IPath> directoryEntries) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * /*from w w w . j av a2s . co m*/ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ import java.io.*; import java.util.*; import java.util.zip.*; import org.eclipse.core.runtime.*; public class Main { private static void zipDirectoryEntry(ZipOutputStream output, IPath entry, long time, Set<IPath> directoryEntries) throws IOException { entry = entry.addTrailingSeparator(); if (!directoryEntries.contains(entry)) { //make sure parent entries are in the zip if (entry.segmentCount() > 1) zipDirectoryEntry(output, entry.removeLastSegments(1), time, directoryEntries); try { ZipEntry dirEntry = new ZipEntry(entry.toString()); dirEntry.setTime(time); output.putNextEntry(dirEntry); directoryEntries.add(entry); } catch (ZipException ze) { //duplicate entries shouldn't happen because we checked the set } finally { try { output.closeEntry(); } catch (IOException e) { // ignore } } } } }