Package java.util.zip

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


    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

    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

    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

      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

    File rarFile = new File(rarName);
    if (rarFile.exists()) {
      ZipFile zipFile = new ZipFile(rarFile.getAbsolutePath());
      for (Enumeration zippedFiles = zipFile.entries(); zippedFiles.hasMoreElements(); ) {
        // Retrieve entry of existing files
        ZipEntry currEntry = (ZipEntry) zippedFiles.nextElement();
        if (debug)
          System.out.println("RAConfig.updateRAR : currEntry = " + currEntry);
        if (currEntry.getName().equalsIgnoreCase(RA_XML)) {
          InputStream reader = zipFile.getInputStream(currEntry);
          createFile("ra.xml",update(reader,map));
          reader.close();
          break;
        }
View Full Code Here

                         "\", path \"" + path +
                         "\", new file \"" + newFileName +
                         "\", old file \"" + oldFileName + "\"");


    ZipEntry entry = null;

    File file = new File(zipName);
    if (file.exists()) {
      ZipFile zipFile = new ZipFile(file.getAbsolutePath());
      Enumeration zipEntries = zipFile.entries();
      // create your output zip file
      ZipOutputStream newZip = new ZipOutputStream(
        new FileOutputStream(new File(file.getAbsolutePath() + "_TMP")));

      // Get all data (except the oldFileName) from zip file and
      // write it to the tmp zip file
      while (zipEntries.hasMoreElements()) {
        entry = (ZipEntry) zipEntries.nextElement();
        if (entry.getName().equalsIgnoreCase(oldFileName))
          continue;
        newZip.putNextEntry(new ZipEntry(entry.getName()));
        InputStream is = zipFile.getInputStream(entry);
        try {
          dump(is,newZip);
        } finally {
          newZip.closeEntry();
          is.close();
        }
      }
      zipFile.close();

      // Write the new fileName to the zip
      entry = new ZipEntry(path);
      newZip.putNextEntry(entry);
      try {
        FileInputStream fis = new FileInputStream(newFileName);
        dump(fis,newZip);
        fis.close();
View Full Code Here

    try {
      byte[] c = new byte[1024];
      int slen;
      zip_in = new CZipInputStream(new FileInputStream(zipPath),"utf-8");
      do {
        ZipEntry file = zip_in.getNextEntry();
        if (file == null)
          break;
       
        // ��ѹ���ŵ�·��
        String fileName = file.getName();
        System.out.println(fileName);
       
        String ext = fileName.substring(fileName.lastIndexOf("."));

        long seed = new Date(System.currentTimeMillis()).getTime();
View Full Code Here

                catch (Exception e) {
                    Plugin.getDefault().logError("Unable to find source for wga version compliance '" + wgaVersion.getMajorVersion() + "." + wgaVersion.getMinorVersion() + "'.");
                    return null;
                }               
                zipIn = new ZipInputStream(sourceIn);
                ZipEntry entry = zipIn.getNextEntry();
                while (entry != null) {
                    String sourceName = entry.getName();
                    sourceName = sourceName.replaceAll("/", ".");
                    if (sourceName.endsWith(".java")) {
                        sourceName = sourceName.substring(0, sourceName.length() - ".java".length());
                    }
                    if (sourceName.equals(classname)) {
View Full Code Here

      // Open the ZIP file
      JarFile zf = new JarFile(getBase());

      // Enumerate each entry
      for (Enumeration<JarEntry> entries = zf.entries(); entries.hasMoreElements();) {
        ZipEntry entry = entries.nextElement();
        mZipFileEntries.put(entry.getName(), entry);
      }
    } catch (IOException e) {
      // If something goes wrong, reset Theme
      mZipFileEntries = new HashMap<String, ZipEntry>();
    }
View Full Code Here

TOP

Related Classes of java.util.zip.ZipEntry

Copyright © 2018 www.massapicom. 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.