Examples of EntryOutputStream


Examples of ch.enterag.utils.zip.EntryOutputStream

          deleteFileEntry(zip64File, testEntry);
          log.info("[insertFileInto] Entry successfully deleted.");
        }
       
        log.info("[insertFileInto] Writing new Entry: " + targetPath);
        EntryOutputStream out = null;
        if(!compress) {
          out = zip64File.openEntryOutputStream(targetPath, FileEntry.iMETHOD_STORED, new Date(toInsert.lastModified()));
        }
        else {
          out = zip64File.openEntryOutputStream(targetPath, FileEntry.iMETHOD_DEFLATED, new Date(toInsert.lastModified()));
        }
       
        if(toInsert.isDirectory()) {
          out.flush();
          out.close();
          log.info("[insertFileInto] Finished writing entry: " + targetPath);
         
          List<String> containedPaths = normalizePaths(toInsert);
          List<File> containedFiles = listAllFilesAndFolders(toInsert, new ArrayList<File>());
         
          log.info("[insertFileInto] Added entry is a folder.");
          log.info("[insertFileInto] Adding all nested files: ");
          for(int i=0;i<containedPaths.size();i++) {
            File currentFile = containedFiles.get(i);
            String currentPath = targetPath.replace("/", "") + File.separator + containedPaths.get(i);
            EntryOutputStream loop_out = null;
            if(!compress) {
              loop_out = zip64File.openEntryOutputStream(currentPath, FileEntry.iMETHOD_STORED, new Date(currentFile.lastModified()));
            }
            else {
              loop_out = zip64File.openEntryOutputStream(currentPath, FileEntry.iMETHOD_DEFLATED, new Date(currentFile.lastModified()));
            }
            if(currentFile.isFile()) {
              InputStream loop_in = new FileInputStream(currentFile);
              IOUtils.copyLarge(loop_in, loop_out);
              loop_in.close();
            }
            log.info("[insertFileInto] Added: " + currentPath);
            loop_out.flush();
            loop_out.close();
          }
        }
        else {
          InputStream in = new FileInputStream(toInsert);
          IOUtils.copyLarge(in, out);
          in.close();
          out.flush();
          out.close();
        }
      }
      else {
        EntryOutputStream out = null;
        if(!compress) {
          out = zip64File.openEntryOutputStream(targetPath, FileEntry.iMETHOD_STORED, new Date(toInsert.lastModified()));
        }
        else {
          out = zip64File.openEntryOutputStream(targetPath, FileEntry.iMETHOD_DEFLATED, new Date(toInsert.lastModified()));
        }
       
        if(toInsert.isDirectory()) {
          out.flush();
          out.close();
          log.info("[insertFileInto] Finished writing entry: " + targetPath);
         
          List<String> containedPaths = normalizePaths(toInsert);
          List<File> containedFiles = listAllFilesAndFolders(toInsert, new ArrayList<File>());
         
          log.info("[insertFileInto] Added entry is a folder.");
          log.info("[insertFileInto] Adding all nested files: ");
         
          for(int i=0;i<containedPaths.size();i++) {
            File currentFile = containedFiles.get(i);
            String currentPath = targetPath.replace("/", "") + File.separator + containedPaths.get(i);
            EntryOutputStream loop_out = null;
            if(!compress) {
              loop_out = zip64File.openEntryOutputStream(currentPath, FileEntry.iMETHOD_STORED, new Date(currentFile.lastModified()));
            }
            else {
              loop_out = zip64File.openEntryOutputStream(currentPath, FileEntry.iMETHOD_DEFLATED, new Date(currentFile.lastModified()));
            }
           
            if(currentFile.isFile()) {
              InputStream loop_in = new FileInputStream(currentFile);
              IOUtils.copyLarge(loop_in, loop_out);
              loop_in.close();
            }
            log.info("[insertFileInto] Added: " + currentPath);
            loop_out.flush();
            loop_out.close();
          }
        }
        else {
          InputStream in = new FileInputStream(toInsert);
          IOUtils.copyLarge(in, out);
View Full Code Here

Examples of ch.enterag.utils.zip.EntryOutputStream

        if(currentEntry!=null) {
          continue;
        }
        else {
          try {
            EntryOutputStream entryWriter = null;
           
            if(!compress) {
              entryWriter = zip64File.openEntryOutputStream(string, FileEntry.iMETHOD_STORED, null);
            }
            else {
              entryWriter = zip64File.openEntryOutputStream(string, FileEntry.iMETHOD_DEFLATED, null);
            }
           
            entryWriter.flush();
            entryWriter.close();
          } catch (FileNotFoundException e) {
            e.printStackTrace();
          } catch (ZipException e) {
            e.printStackTrace();
          } catch (IOException e) {
View Full Code Here

Examples of ch.enterag.utils.zip.EntryOutputStream

  }
 
 
  private static FileEntry writeEntry(Zip64File zip64File, FileEntry targetPath, File toWrite, boolean compress) {
    InputStream in = null;
    EntryOutputStream out = null;
   
    processAndCreateFolderEntries(zip64File, parseTargetPath(targetPath.getName(), toWrite), compress);
   
    try {
     
      if(!compress) {
        out = zip64File.openEntryOutputStream(targetPath.getName(), FileEntry.iMETHOD_STORED, getFileDate(toWrite));
      }
      else {
        out = zip64File.openEntryOutputStream(targetPath.getName(), FileEntry.iMETHOD_DEFLATED, getFileDate(toWrite));
      }
     
     
      if(!targetPath.isDirectory()) {
        in = new FileInputStream(toWrite);
        IOUtils.copyLarge(in, out);
        in.close();
      }
      out.flush();
      out.close();
      if(targetPath.isDirectory()) {
        log.info("[createZip] Written folder entry to zip: " + targetPath.getName());
      }
      else {
        log.info("[createZip] Written file entry to zip: " + targetPath.getName());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.