Turns temporary folder "foo" into a jar file "foo.jar".

@param file
@return
@throws IOException
175683
private static File toJar(final File file) throws IOException {
    final File tempFolder = Files.createTempDirectory("reef-tmp-tempFolder").toFile();
    final File jarFile = File.createTempFile(file.getCanonicalFile().getName(), ".jar", tempFolder);
    LOG.log(Level.FINEST, "Adding contents of folder {0} to {1}", new Object[]{file, jarFile});
    try (final JARFileMaker jarMaker = new JARFileMaker(jarFile)) {
      jarMaker.addChildren(file);
    }
    return jarFile;
  }
223812
public void jarDir(File dirOrFile2Jar, File destJar)
		throws IOException {

		if (dirOrFile2Jar == null || destJar == null) {
			throw new IllegalArgumentException();
		}

		mDestJarName = destJar.getCanonicalPath();
		FileOutputStream fout = new FileOutputStream(destJar);
		JarOutputStream jout = new JarOutputStream(fout);
		//jout.setLevel(0);
		try {
			jarDir(dirOrFile2Jar, jout, null);
		} catch (IOException ioe) {
			throw ioe;
		} finally {
			jout.close();
			fout.close();
		}
	}
1343831
public static InputStream inputStream(File file) {
        // workaround http://stackoverflow.com/questions/36880692/java-file-does-not-exists-but-file-getabsolutefile-exists
        if (!file.exists()) {
            file = file.getAbsoluteFile();
        }
        if (!file.exists()) {
            throw E.ioException("File does not exists: %s", file.getPath());
        }
        try {
            return new FileInputStream(file);
        } catch (FileNotFoundException e) {
            throw E.ioException(e);
        }
    }
1227794
public static Map<String, String> processArchiveManifest(final File file) throws Throwable {
        Map<String, String> manifestAttrs = null;

        if (file != null && file.isFile() && ArchiveFileType.JAR.isType(file.getPath())) {
            JarFile jarFile = null;
            try {
                jarFile = new JarFile(file);
                manifestAttrs = processArchiveManifest(jarFile);
            } finally {
                if (jarFile != null) {
                    InstallUtils.close(jarFile);
                }
            }
        }

        return manifestAttrs;
    }
955955
public InputStream load(String folder, String file) throws IOException {
      if (content.containsKey(folder+"/"+file))
        return new ByteArrayInputStream(content.get(folder+"/"+file));
      else {
        File f = new File(Utilities.path(path, folder, file));
        if (f.exists())
          return new FileInputStream(f);
        throw new IOException("Unable to find the file "+folder+"/"+file+" in the package "+name());
      }
    }
71405
public SourceFile getSourceFile(File file) throws IOException
	{
		SourceFile source = sourceFiles.get(file);

		if (source == null)
		{
			source = new SourceFile(file);
			sourceFiles.put(file, source);
		}

		return source;
	}
801709
private File createDir(String path) throws IOException {
		// In windows, pathnames with spaces are returned as %20
		if (path.contains("%20"))
			path = path.replaceAll("%20", " ");
		File dir = new File(path);
		if (!dir.exists() && !dir.mkdirs())
			throw new BundlingProcessException("Error creating temporary jawr directory with path:" + dir.getPath());

		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("Created dir: " + dir.getCanonicalPath());
		}
		return dir;
	}
470425
private File expandScriptPlugin(final File file) throws IOException {
        if (!cachedir.exists()) {
            if (!cachedir.mkdirs()) {
                log.warn("Unable to create cache dir: " + cachedir.getAbsolutePath());
            }
        }
        final File jardir = getFileCacheDir();
        if (!jardir.exists()) {
            if (!jardir.mkdir()) {
                log.warn("Unable to create cache dir for plugin: " + jardir.getAbsolutePath());
            }
        }
        final String prefix = getFileBasename() + "/contents";

        debug("Expand zip " + file.getAbsolutePath() + " to dir: " + jardir + ", prefix: " + prefix);
        ZipUtil.extractZip(file.getAbsolutePath(), jardir, prefix, prefix + "/");

        return jardir;
    }
963820
public static void writeToFile(byte[] catalogBytes, File file) throws IOException {
        JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(file));

        JarInputStream jarIn = new JarInputStream(new ByteArrayInputStream(catalogBytes));
        JarEntry catEntry = null;
        JarInputStreamReader reader = new JarInputStreamReader();
        while ((catEntry = jarIn.getNextJarEntry()) != null) {
            byte[] value = reader.readEntryFromStream(jarIn);
            String key = catEntry.getName();

            assert (value != null);
            JarEntry entry = new JarEntry(key);
            entry.setSize(value.length);
            entry.setTime(System.currentTimeMillis());
            jarOut.putNextEntry(entry);
            jarOut.write(value);
            jarOut.flush();
            jarOut.closeEntry();
        }

        jarOut.finish();
        jarIn.close();
    }
552441
public static File getTempFileFor(File file) {
    File parent = file.getParentFile();
    String name = file.getName();
    File result;
    int index = 0;
    do {
      result = new File(parent, name + "_" + index++);
    }
    while (result.exists());
    return result;
  }
997957
public Jar setJarPrefix(Path file) {
        verifyNotSealed();
        if (jos != null)
            throw new IllegalStateException("Really executable cannot be set after entries are added.");
        if (file != null && jarPrefixStr != null)
            throw new IllegalStateException("A prefix has already been set (" + jarPrefixStr + ")");
        this.jarPrefixFile = file;
        return this;
    }
116810
private void findJarFile() throws IOException {
        if (getUseCaches()) {
            synchronized (jarCache) {
                jarFile = jarCache.get(jarFileURL);
            }
            if (jarFile == null) {
                JarFile jar = openJarFile();
                synchronized (jarCache) {
                    jarFile = jarCache.get(jarFileURL);
                    if (jarFile == null) {
                        jarCache.put(jarFileURL, jar);
                        jarFile = jar;
                    } else {
                        jar.close();
                    }
                }
            }
        } else {
            jarFile = openJarFile();
        }

        if (jarFile == null) {
            throw new IOException();
        }
    }
1364185
public static String slurpFile(File file) throws IOException {
    Reader r = new FileReader(file);
    return IOUtils.slurpReader(r);
  }
278201
private static File createTempFile() throws IOException
  {
    File file = File.createTempFile(TMP_FILE_PREFIX, TMP_FILE_EXTENSION);
    file.deleteOnExit();
    return file;
  }
519048
public static Properties fromFile(
    final File file)
    throws IOException
  {
    Objects.requireNonNull(file, "File");

    try (InputStream stream = Files.newInputStream(file.toPath())) {
      final Properties p = new Properties();
      p.load(stream);
      return p;
    }
  }
531861
public static SwapFile createTempFile(String prefix, String suffix, File directory) throws IOException
   {
      throw new IOException("Not applicable. Call get(File, String) method instead");
   }
1203441
public static Properties loadFile(File file) throws IOException {
		InputStream input = new FileInputStream(file);
		Properties prop = null;
		try {
			prop = load(input);
		} finally {
			IOUtils.close(input);
		}
		return prop;
	}