Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void zipDir(String dir2zip, ZipOutputStream zos){
- try{
- File zipDir = new File(dir2zip);
- String[] dirList = zipDir.list();
- byte[] readBuffer = new byte[2156];
- int bytesIn = 0;
- for (String file : dirList) {
- File f = new File(zipDir, file);
- if (f.isDirectory()) {
- String filePath = f.getPath();
- zipDir(filePath, zos);
- }else{
- FileInputStream fis = new FileInputStream(f);
- ZipEntry anEntry = new ZipEntry(f.getPath());
- zos.putNextEntry(anEntry);
- while ((bytesIn = fis.read(readBuffer)) != -1) {
- zos.write(readBuffer, 0, bytesIn);
- }
- fis.close();
- }
- }
- zos.close();
- }catch(Exception e){
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement