private static void copyEntryToFile(JarFile jar, JarEntry source, File dest)
            throws IOException {

        int length;
        byte[] buffer = new byte[8192];

        try (InputStream input = jar.getInputStream(source)) {
            try (OutputStream output = new FileOutputStream(dest)) {

                while ((length = input.read(buffer)) > 0) {
                    output.write(buffer, 0, length);
                }

            }
        }

    }
Copies all bytes of data from a file within a .jar to a destination
file.

@param jar
    The JarFile containing the file to be copied.

@param source
    The JarEntry representing the file to be copied within the given
    JarFile.

@param dest
    The destination file that the data should be copied to.

@throws IOException
    If an error occurs reading from the source .jar or writing to the
    destination file.
guacamole/src/main/java/org/apache/guacamole/extension/ExtensionClassLoader.java