public static void copyFile(File source, File target) throws IOException { try (FileInputStream in = new FileInputStream(source); FileOutputStream out = new FileOutputStream(target)) { copyStream(in, out); } }
@Override public void copyEntry(String source, String path, String archiveName, String entryName) { String file = new File(getAbsolutePath(path), archiveName).getPath(); if (!checkEntry(entryName, file)) { return; } try (ZipFile srcArchive = new ZipFile(new File(source))) { ZipEntry entry = srcArchive.getEntry(entryName); if (entry != null) { try (InputStream in = srcArchive.getInputStream(entry)) { ZipOutputStream out = mapArchiveStreams.get(file); out.putNextEntry(new ZipEntry(entryName)); InterpreterUtil.copyStream(in, out); } } } catch (IOException ex) { String message = "Cannot copy entry " + entryName + " from " + source + " to " + file; DecompilerContext.getLogger().writeMessage(message, ex); } }
private static void unpack(File archive, File targetDir) { try (ZipFile zip = new ZipFile(archive)) { Enumeration<? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (!entry.isDirectory()) { File file = new File(targetDir, entry.getName()); assertTrue(file.getParentFile().mkdirs() || file.getParentFile().isDirectory()); try (InputStream in = zip.getInputStream(entry); OutputStream out = new FileOutputStream(file)) { InterpreterUtil.copyStream(in, out); } } } } catch (IOException e) { throw new RuntimeException(e); } } }
public static void copyFile(File source, File target) throws IOException { try (FileInputStream in = new FileInputStream(source); FileOutputStream out = new FileOutputStream(target)) { copyStream(in, out); } }
@Override public void copyEntry(String source, String path, String archiveName, String entryName) { String file = new File(getAbsolutePath(path), archiveName).getPath(); if (!checkEntry(entryName, file)) { return; } try (ZipFile srcArchive = new ZipFile(new File(source))) { ZipEntry entry = srcArchive.getEntry(entryName); if (entry != null) { try (InputStream in = srcArchive.getInputStream(entry)) { ZipOutputStream out = mapArchiveStreams.get(file); out.putNextEntry(new ZipEntry(entryName)); InterpreterUtil.copyStream(in, out); } } } catch (IOException ex) { String message = "Cannot copy entry " + entryName + " from " + source + " to " + file; DecompilerContext.getLogger().writeMessage(message, ex); } }
@Override public void copyEntry(String source, String path, String archiveName, String entryName) { String file = new File(getAbsolutePath(path), archiveName).getPath(); if (!checkEntry(entryName, file)) { return; } try (ZipFile srcArchive = new ZipFile(new File(source))) { ZipEntry entry = srcArchive.getEntry(entryName); if (entry != null) { try (InputStream in = srcArchive.getInputStream(entry)) { ZipOutputStream out = mapArchiveStreams.get(file); try { out.putNextEntry(new ZipEntry(entryName)); InterpreterUtil.copyStream(in, out); } finally { out.closeEntry(); } } } } catch (IOException ex) { String message = "Cannot copy entry " + entryName + " from " + source + " to " + file; DecompilerContext.getLogger().writeMessage(message, ex); } }