Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void generateJarFile(String from, String location, String name) throws IOException {
- String myJarPath = location + name + ".jar";
- File file = new File(myJarPath);
- JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(file));
- File[] toInputFiles = new File(from).listFiles();
- assert toInputFiles != null;
- for (File singleFile : toInputFiles) {
- JarEntry jarEntry = new JarEntry(singleFile.getPath());
- jarOutputStream.putNextEntry(jarEntry);
- InputStream inputStream = new FileInputStream(singleFile);
- jarOutputStream.write(inputStream.read());
- inputStream.close();
- }
- jarOutputStream.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement