Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void addToArchiveCompression(SevenZOutputFile out, File file, String dir) throws IOException {
- String name = dir + File.separator + file.getName();
- if (file.isFile()){
- SevenZArchiveEntry entry = out.createArchiveEntry(file, name);
- out.putArchiveEntry(entry);
- FileInputStream in = new FileInputStream(file);
- byte[] b = new byte[1024];
- int count = 0;
- while ((count = in.read(b)) > 0) {
- out.write(b, 0, count);
- }
- out.closeArchiveEntry();
- } else if (file.isDirectory()) {
- File[] children = file.listFiles();
- if (children != null){
- for (File child : children){
- addToArchiveCompression(out, child, name);
- }
- }
- } else {
- System.out.println(file.getName() + " is not supported");
- }
- }
- byte[] arr = new byte[1024];
- SevenZOutputFile file = new SevenZOutputFile(new SeekableInMemoryByteChannel(arr));
- addToArchiveCompression(file, ...);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement