Examples of ZipEntry


Examples of java.util.zip.ZipEntry

        try {
            String entryName = getEntryName(fileName);
            ZipInputStream file = openZip(fileName);
            long result = 0;
            while (true) {
                ZipEntry entry = file.getNextEntry();
                if (entry == null) {
                    break;
                }
                if (entry.getName().equals(entryName)) {
                    result = entry.getSize();
                    if (result == -1) {
                        result = 0;
                        while (true) {
                            long x = file.skip(16 * Constants.IO_BUFFER_SIZE);
                            if (x == 0) {
View Full Code Here

Examples of java.util.zip.ZipEntry

            ZipInputStream file = openZip(path);
            String dirName = getEntryName(path);
            String prefix = path.substring(0, path.length() - dirName.length());
            ArrayList<String> list = New.arrayList();
            while (true) {
                ZipEntry entry = file.getNextEntry();
                if (entry == null) {
                    break;
                }
                String name = entry.getName();
                if (name.startsWith(dirName) && name.length() > dirName.length()) {
                    int idx = name.indexOf('/', dirName.length());
                    if (idx < 0 || idx >= name.length() - 1) {
                        list.add(prefix + name);
                    }
View Full Code Here

Examples of java.util.zip.ZipEntry

        if (entryName.length() == 0) {
            throw new FileNotFoundException(fileName);
        }
        ZipInputStream in = openZip(fileName);
        while (true) {
            ZipEntry entry = in.getNextEntry();
            if (entry == null) {
                break;
            }
            if (entry.getName().equals(entryName)) {
                return new FileObjectZip2(fileName, entryName, in, length(fileName));
            }
            in.closeEntry();
        }
        in.close();
View Full Code Here

Examples of java.util.zip.ZipEntry

            zipOut.setLevel(Deflater.BEST_COMPRESSION);
            for (File file : files) {
                String fileName = file.getPath();
                String entryName = removeBase(basePath, fileName);
                byte[] data = readFile(file);
                ZipEntry entry = new ZipEntry(entryName);
                CRC32 crc = new CRC32();
                crc.update(data);
                entry.setSize(file.length());
                entry.setCrc(crc.getValue());
                zipOut.putNextEntry(entry);
                zipOut.write(data);
                zipOut.closeEntry();
            }
            zipOut.closeEntry();
View Full Code Here

Examples of java.util.zip.ZipEntry

                if (IOUtils.isDirectory(fileName)) {
                    continue;
                }
                f = f.substring(base.length());
                f = BackupCommand.correctFileName(f);
                ZipEntry entry = new ZipEntry(f);
                zipOut.putNextEntry(entry);
                InputStream in = null;
                try {
                    in = IOUtils.openFileInputStream(fileName);
                    IOUtils.copyAndCloseInput(in, zipOut);
View Full Code Here

Examples of java.util.zip.ZipEntry

        InputStream in = null;
        try {
            in = IOUtils.openFileInputStream(zipFileName);
            ZipInputStream zipIn = new ZipInputStream(in);
            while (true) {
                ZipEntry entry = zipIn.getNextEntry();
                if (entry == null) {
                    break;
                }
                String fileName = entry.getName();
                // restoring windows backups on linux and vice versa
                fileName = fileName.replace('\\', SysProperties.FILE_SEPARATOR.charAt(0));
                fileName = fileName.replace('/', SysProperties.FILE_SEPARATOR.charAt(0));
                if (fileName.startsWith(SysProperties.FILE_SEPARATOR)) {
                    fileName = fileName.substring(1);
View Full Code Here

Examples of java.util.zip.ZipEntry

    File file = new File(rarName);
    if (file.exists()) {
      ZipFile zipFile = new ZipFile(file.getAbsolutePath());
      for (Enumeration zippedFiles = zipFile.entries(); zippedFiles.hasMoreElements(); ) {
        //Retrieve entry of existing files
        ZipEntry currEntry = (ZipEntry) zippedFiles.nextElement();
        if (debug)
          System.out.println("RAConfig.createRaProperties : currEntry = " + currEntry);
        if (currEntry.getName().equalsIgnoreCase(RA_XML)) {
          InputStream reader = zipFile.getInputStream(currEntry);
          StringBuffer buff = new StringBuffer();
          buff.append("RAR_NAME  ");
          buff.append(file.getAbsolutePath());
          buff.append("\n");
View Full Code Here

Examples of java.util.zip.ZipEntry

    File file = new File(rarName);
    if (file.exists()) {
      ZipFile zipFile = new ZipFile(file.getAbsolutePath());
      for (Enumeration zippedFiles = zipFile.entries(); zippedFiles.hasMoreElements(); ) {
        //Retrieve entry of existing files
        ZipEntry currEntry = (ZipEntry) zippedFiles.nextElement();
        if (debug)
          System.out.println("RAConfig.extractFromRAR : currEntry = " + currEntry);
        if (currEntry.getName().equalsIgnoreCase(fileName)
            || currEntry.getName().equalsIgnoreCase("META-INF/"+fileName)) {
          // the fileName is found.
          res =  zipFile.getInputStream(currEntry);
          break;
        } else if (currEntry.getName().endsWith(".jar")) {
          // search fileName in jar file.
          InputStream reader = zipFile.getInputStream(currEntry);
          res = extractFromJAR(fileName,reader);
          if (res == null) continue;
         
View Full Code Here

Examples of java.util.zip.ZipEntry

    if (debug)
      System.out.println("RAConfig.extractFromJAR(" + fileName +  "," + reader + ")");

    ZipInputStream stream = new ZipInputStream(reader);
    ZipEntry currEntry = stream.getNextEntry();
    while (stream.available() > 0) {
      if (currEntry == null) break;
      if (currEntry.getName().equalsIgnoreCase(fileName)) {
        // the fileName is found, return the InputStream.
        if (debug)
          System.out.println("RAConfig.extractFromJAR : currEntry = " + currEntry);
        else if (verbose)
          System.out.println("extract \"" + fileName + "\" from JAR.");
View Full Code Here

Examples of java.util.zip.ZipEntry

      System.out.println("RAConfig.extractFromJAR(" + jarName +  "," + fileName + ")");
    else if (verbose)
      System.out.println("extract \"" + fileName + "\" from \"" + jarName + "\"");

    JarFile jar = new JarFile(jarName);
    ZipEntry entry = jar.getEntry(fileName);
    if (debug)
      System.out.println("RAConfig.extractFromJAR : entry = " + entry);
    // extract the fileName from jar in the tmp directory.
    if (entry != null)
      createFile(fileName,jar.getInputStream(entry));
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.