private void copyStream(final InputStream stream, final File toFile) throws IOException { try (FileOutputStream out = new FileOutputStream(toFile)) { IOUtil.copyFile(stream, out); } }
private void copyStream(final InputStream stream, final File toFile) throws IOException { try (FileOutputStream out = new FileOutputStream(toFile)) { IOUtil.copyFile(stream, out); } }
private void copyStream(final InputStream stream, final File toFile) throws IOException { final FileOutputStream out = new FileOutputStream(toFile); try { IOUtil.copyFile(stream, out); } finally { out.close(); } }
/** * Unjars the given file to the given directory. Does not close the JarFile * when finished. * * @param jarFile * The file to unjar. * @param toDir * The directory to unjar to. */ public static void unjar(final JarFile jarFile, final File toDir) throws IOException { final Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { final JarEntry entry = entries.nextElement(); final File outFile = new File(toDir, entry.getName()); FileOutputStream fos = null; InputStream in = null; try { fos = new FileOutputStream(outFile); in = jarFile.getInputStream(entry); IOUtil.copyFile(in, fos); } finally { if (in != null) { in.close(); } if (fos != null) { fos.close(); } } } }
/** * Unjars the given file to the given directory. Does not close the JarFile * when finished. * * @param jarFile * The file to unjar. * @param toDir * The directory to unjar to. */ public static void unjar(JarFile jarFile, File toDir) throws IOException { Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); File outFile = new File(toDir, entry.getName()); FileOutputStream fos = null; try { fos = new FileOutputStream(outFile); InputStream in = jarFile.getInputStream(entry); IOUtil.copyFile(in, fos); } finally { if (fos != null) { fos.close(); } } } }
/** * Extracts the resource to a file. * * @param clazz * The class, relative to which path is resolved * @param path * The path to the resource * @param file * The file to extract to * @throws IOException * If an error occurs reading it */ public static void extractResourceToFile(final Class<?> clazz, final String path, final File file) throws IOException { final InputStream in = getResourceAsStream(clazz, path); if (in == null) { throw new IOException("Missing resource: " + path); } OutputStream out = null; try { out = new FileOutputStream(file); IOUtil.copyFile(in, out); } finally { if (out != null) { out.close(); } in.close(); } }
/** * Unjars the given file to the given directory. Does not close the JarFile * when finished. * * @param jarFile * The file to unjar. * @param toDir * The directory to unjar to. */ public static void unjar(final JarFile jarFile, final File toDir) throws IOException { final Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { final JarEntry entry = entries.nextElement(); final File outFile = new File(toDir, entry.getName()); FileOutputStream fos = null; InputStream in = null; try { fos = new FileOutputStream(outFile); in = jarFile.getInputStream(entry); IOUtil.copyFile(in, fos); } finally { if (in != null) { in.close(); } if (fos != null) { fos.close(); } } } }
/** * Extracts the resource to a file. * * @param clazz * The class, relative to which path is resolved * @param path * The path to the resource * @param file * The file to extract to * @throws IOException * If an error occurs reading it */ public static void extractResourceToFile(final Class<?> clazz, final String path, final File file) throws IOException { final InputStream in = getResourceAsStream(clazz, path); if (in == null) { throw new IOException("Missing resource: " + path); } OutputStream out = null; try { out = new FileOutputStream(file); IOUtil.copyFile(in, out); } finally { if (out != null) { out.close(); } in.close(); } }
try { out = new FileOutputStream(file); IOUtil.copyFile(in, out); } finally { if ( out != null ) {
ret = copyFile(fis, fout) > 0; } finally {
ret = copyFile(fis, fout) > 0; } finally {
ret = copyFile(fis, fout) > 0; } finally {