Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File zip = new File("/Users/ossiemoore/tmp/zipstuff/file.zip");
- File addition = new File("/Users/ossiemoore/tmp/zipstuff/theme.xml");
- Map<String, String> env = new HashMap<>();
- env.put("create", "true");
- Path path = Paths.get(zip.getAbsolutePath());
- String uriPath = "jar:" + path.toUri();
- URI uri = URI.create(uriPath);
- try (FileSystem fs = FileSystems.newFileSystem(uri, env)) {
- int size = (int)addition.length();
- byte [] data = new byte[size];
- InputStream is = new FileInputStream(addition);
- is.read(data);
- Path themeDir = fs.getPath("theme");
- Files.createDirectory(themeDir);
- Path nfInZip = fs.getPath("theme/theme1.xml");
- try (Writer writer = Files.newBufferedWriter(nfInZip, StandardCharsets.UTF_8, StandardOpenOption.CREATE)) {
- writer.write(new String(data));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment