Write all entries from the specified jar file.

@param jarFile the source jar file
@throws IOException if the entries cannot be written
763248
public void writeEntries(JarFile jarFile) throws IOException {
        Enumeration<JarEntry> entries = jarFile.entries();
        while (entries.hasMoreElements()) {
            JarEntry entry = entries.nextElement();
            ZipHeaderPeekInputStream inputStream = new ZipHeaderPeekInputStream(
                    jarFile.getInputStream(entry));
            try {
                if (inputStream.hasZipHeader() && entry.getMethod() != ZipEntry.STORED) {
                    new CrcAndSize(inputStream).setupStoredEntry(entry);
                    inputStream.close();
                    inputStream = new ZipHeaderPeekInputStream(
                            jarFile.getInputStream(entry));
                }
                EntryWriter entryWriter = new InputStreamEntryWriter(inputStream, true);
                writeEntry(entry, entryWriter);
            } finally {
                inputStream.close();
            }
        }
    }
1363847
private void writeEntry(final InputStream input, final JarEntry entry) throws IOException {

		// add the entry to the jar archive
		jarOutputStream.putNextEntry(entry);

		// read the content of the entry from the input stream, and write it into the archive.
		int count;

		while ((count = input.read(buffer)) != -1) {

			jarOutputStream.write(buffer, 0, count);

			if (messageDigest != null) {
				messageDigest.update(buffer, 0, count);
			}
		}

		jarOutputStream.closeEntry();

		if (manifest != null) {

			Attributes attr = manifest.getAttributes(entry.getName());
			if (attr == null) {

				attr = new Attributes();
				manifest.getEntries().put(entry.getName(), attr);
			}

			attr.putValue("SHA1-Digest", new String(Base64.encode(messageDigest.digest()), "ASCII"));
		}
	}
637984
public void writeToFile() throws IOException {
        FileOutputStream fos = new FileOutputStream(new File(this.hashFunctionFile));
        store(fos);
        fos.close();
    }
178749
public static void writeFile(File file, byte[] bytes) throws IOException {
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(file);
            fos.write(bytes);
        } finally {
            if (fos != null) {
                fos.close();
            }
        }
    }
1057348
public void writeObject (ObjectOutputStream out)
        throws IOException
    {
        int ecount = size();
        out.writeInt(ecount);
        for (IntEntry<V> entry : intEntrySet()) {
            out.writeInt(entry.getIntKey());
            out.writeObject(entry.getValue());
        }
    }
893490
@Override
	protected void writeTo(JournalFile journalFile) throws JournalException
    {
    	super.writeTo(journalFile);
    	journalFile.writeInt(operationsCount);
    }
902403
public static void writeSymbolToFileEntries(final Iterable<Map.Entry<Symbol, File>> entries,
      final CharSink sink) throws IOException {

    writeUnixLines(
        transform(
            MapUtils.transformValues(entries, toAbsolutePathFunction()),
            TO_TAB_SEPARATED_ENTRY),
        sink);
  }
1293938
private final void readDirectories(final URL jarFile) {
		JarInputStream jarIn = null;

		try {
			if (!jarFile.getPath().endsWith(".jar")) {
				return;
			}
			if (CClassLoader.sl(CClassLoader.DEBUG)) {
				CClassLoader.log("opening jar : " + jarFile.toExternalForm(),
						CClassLoader.DEBUG);
			}
			jarIn = new JarInputStream(jarFile.openStream());
			JarEntry jarEntry = null;

			while ((jarEntry = jarIn.getNextJarEntry()) != null) {
				if (jarEntry.isDirectory()) {
					continue;
				}

				final URL url = new URL("yahpjarloader://"
						+ CBASE64Codec.encode(
								jarFile.toExternalForm().getBytes("utf-8"))
								.replaceAll("\n", "") + "/"
						+ jarEntry.getName());

				if (CClassLoader.sl(CClassLoader.DEBUG)) {
					CClassLoader.log("found entry : " + url.toString(),
							CClassLoader.DEBUG);
				}

				if (jarEntry.getName().endsWith(".class")) {
					if (!this.classesMap.containsKey(jarEntry.getName())) {
						if (!this.booResourceOnly) {
							this.classesMap.put(jarEntry.getName(), url);
						}
					}

					if (this.resourcesMap.containsKey(jarEntry.getName())) {
						final Object to = this.resourcesMap.get(jarEntry
								.getName());
						if (to instanceof URL) {
							final URL uo = (URL) to;
							final List l = new ArrayList();
							l.add(uo);
							l.add(url);
							this.resourcesMap.put(jarEntry.getName(), l);
						} else if (to instanceof List) {
							final List uo = (List) to;
							uo.add(url);
							this.resourcesMap.put(jarEntry.getName(), uo);
						}
					} else {
						this.resourcesMap.put(jarEntry.getName(), url);
					}
				} else if (jarEntry.getName().startsWith("native/")) {
					String system = jarEntry.getName().substring(7);
					system = system.substring(0, system.indexOf('/'));
					if (!this.dllMap.containsKey(system)) {
						this.dllMap.put(system, url);
					}
					if (this.resourcesMap.containsKey(jarEntry.getName())) {
						final Object to = this.resourcesMap.get(jarEntry
								.getName());
						if (to instanceof URL) {
							final URL uo = (URL) to;
							final List l = new ArrayList();
							l.add(uo);
							l.add(url);
							this.resourcesMap.put(jarEntry.getName(), l);
						} else if (to instanceof List) {
							final List uo = (List) to;
							uo.add(url);
							this.resourcesMap.put(jarEntry.getName(), uo);
						}
					} else {
						this.resourcesMap.put(jarEntry.getName(), url);
					}
				} else {
					if (this.resourcesMap.containsKey(jarEntry.getName())) {
						final Object to = this.resourcesMap.get(jarEntry
								.getName());
						if (to instanceof URL) {
							final URL uo = (URL) to;
							final List l = new ArrayList();
							l.add(uo);
							l.add(url);
							this.resourcesMap.put(jarEntry.getName(), l);
						} else if (to instanceof List) {
							final List uo = (List) to;
							uo.add(url);
							this.resourcesMap.put(jarEntry.getName(), uo);
						}
					} else {
						this.resourcesMap.put(jarEntry.getName(), url);
					}
				}
			}

			if (CClassLoader.sl(CClassLoader.DEBUG)) {
				CClassLoader.log("opening jar : "
						+ jarFile.getFile().toString() + " done.",
						CClassLoader.DEBUG);
			}
		} catch (final MalformedURLException mue) {
			mue.printStackTrace();

			if (CClassLoader.sl(CClassLoader.FATAL)) {
				CClassLoader.log(mue.getMessage(), CClassLoader.FATAL);
			}
		} catch (final IOException ioe) {
			ioe.printStackTrace();

			if (CClassLoader.sl(CClassLoader.FATAL)) {
				CClassLoader.log(ioe.getMessage(), CClassLoader.FATAL);
			}
		} catch (final Exception e) {
			e.printStackTrace();

			if (CClassLoader.sl(CClassLoader.FATAL)) {
				CClassLoader.log(e.getMessage(), CClassLoader.FATAL);
			}
		} finally {
			try {
				jarIn.close();
				jarIn = null;
			} catch (final Exception e) {
			}
		}
	}
924597
private void writeFile() throws IOException {
        historyFile.delete();
        try (FileWriter fw = new FileWriter(historyFile)) {
            for(int i=0; i < size();i++)
                fw.write(Parser.fromCodePoints(get(i)) + (Config.getLineSeparator()));
        }
        if (historyFilePermission != null) {
            historyFile.setReadable(false, false);
            historyFile.setReadable(historyFilePermission.isReadable(), historyFilePermission.isReadableOwnerOnly());
            historyFile.setWritable(false, false);
            historyFile.setWritable(historyFilePermission.isWritable(), historyFilePermission.isWritableOwnerOnly());
            historyFile.setExecutable(false, false);
            historyFile.setExecutable(historyFilePermission.isExecutable(),
                    historyFilePermission.isExecutableOwnerOnly());
        }
    }
664506
public void addJarFile(String jarFile)
    {
        if (jarFiles == null)
        {
            jarFiles = new HashSet<String>();
        }
        this.jarFiles.add(jarFile);
        addJarFileUrl(jarFile);

    }
279749
public static void writeFile( List<String> lines, File file ) throws IOException {
        try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) {
            for( String line : lines ) {
                bw.write(line);
                bw.write("\n"); //$NON-NLS-1$
            }
        }
    }
19482
public synchronized void release()
    {
        _list=null;
        _entry=null;
        _file=null;
        _jarFile=null;
        super.release();
    }
503766
public void processJars(File[] jarFiles, File destDir) throws IOException {
        for (int i = 0; i < jarFiles.length; i++) {
            processFile(jarFiles[i], destDir);
        }
    }
645441
private void writeEntry(InputStream input, JarEntry entry) throws IOException {
        // add the entry to the jar archive
        mOutputJar.putNextEntry(entry);

        // read the content of the entry from the input stream, and write it into the archive.
        int count;
        while ((count = input.read(mBuffer)) != -1) {
            mOutputJar.write(mBuffer, 0, count);

            // update the digest
            if (mMessageDigest != null) {
                mMessageDigest.update(mBuffer, 0, count);
            }
        }

        // close the entry for this file
        mOutputJar.closeEntry();

        if (mManifest != null) {
            // update the manifest for this entry.
            Attributes attr = mManifest.getAttributes(entry.getName());
            if (attr == null) {
                attr = new Attributes();
                mManifest.getEntries().put(entry.getName(), attr);
            }
            attr.putValue(DIGEST_ATTR, mBase64Encoder.encodeToString(mMessageDigest.digest()));
        }
    }
229884
public static JarClassLoader loadJar(File jarFile) {
		final JarClassLoader loader = new JarClassLoader();
		loader.addJar(jarFile);
		return loader;
	}
951784
public void addEntry(File srcFile, File destFile) {
        entries.add(new Entry(srcFile,destFile));
    }
204672
public void writeObject (ObjectOutputStream out)
        throws IOException
    {
        out.writeInt(_size);
        for (int ii = 0; ii < _size; ii++) {
            out.writeObject(_entries[ii]);
        }
    }