當前位置: 首頁>>代碼示例>>Java>>正文


Java ZipInputStream.closeEntry方法代碼示例

本文整理匯總了Java中java.util.zip.ZipInputStream.closeEntry方法的典型用法代碼示例。如果您正苦於以下問題:Java ZipInputStream.closeEntry方法的具體用法?Java ZipInputStream.closeEntry怎麽用?Java ZipInputStream.closeEntry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.zip.ZipInputStream的用法示例。


在下文中一共展示了ZipInputStream.closeEntry方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: expandZippedApplication

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
private void expandZippedApplication(InputStream stream, ApplicationDescription desc)
        throws IOException {
    ZipInputStream zis = new ZipInputStream(stream);
    ZipEntry entry;
    File appDir = new File(appsDir, desc.name());
    while ((entry = zis.getNextEntry()) != null) {
        if (!entry.isDirectory()) {
            byte[] data = ByteStreams.toByteArray(zis);
            zis.closeEntry();
            File file = new File(appDir, entry.getName());
            createParentDirs(file);
            write(data, file);
        }
    }
    zis.close();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:17,代碼來源:ApplicationArchive.java

示例2: InMemoryZipFile

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
public InMemoryZipFile(byte[] zipBuffer) throws IOException {
    ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(zipBuffer));

    while(true) {
        ZipEntry entry;
        do {
            if((entry = zin.getNextEntry()) == null) {
                zin.close();
                return;
            }
        } while(entry.isDirectory());

        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        byte[] buf = new byte[10240];

        int length;
        while((length = zin.read(buf)) != -1) {
            buffer.write(buf, 0, length);
        }

        zin.closeEntry();
        this.contents.put(entry.getName(), buffer.toByteArray());
    }
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:25,代碼來源:InMemoryZipFile.java

示例3: unzip

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
public static void unzip(String zipFilePath, String destDirectory) throws IOException {
    File destDir = new File(destDirectory);
    if (!destDir.exists()) {
        destDir.mkdir();
    }
    ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));
    ZipEntry entry = zipIn.getNextEntry();
    // iterates over entries in the zip file
    while (entry != null) {
        String filePath = destDirectory + File.separator + entry.getName();
        if (!entry.isDirectory()) {
            // if the entry is a file, extracts it
            extractFile(zipIn, filePath);
        } else {
            // if the entry is a directory, make the directory
            File dir = new File(filePath);
            dir.mkdir();
        }
        zipIn.closeEntry();
        entry = zipIn.getNextEntry();
    }
    zipIn.close();
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:24,代碼來源:UnzipFiles.java

示例4: unzipRemoteFile

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
public static void unzipRemoteFile(String localFileName, String directoryPath){
    try  {
        FileInputStream fin = new FileInputStream(localFileName);
        ZipInputStream zin = new ZipInputStream(fin);
        ZipEntry ze = null;
        while ((ze = zin.getNextEntry()) != null) {
            Log.v("Decompress", "Unzipping " + ze.getName());

            if(ze.isDirectory()) {
                Common.dirChecker(directoryPath + File.separator + ze.getName());
            } else {
                FileOutputStream fout = new FileOutputStream(directoryPath + File.separator + ze.getName());
                for (int c = zin.read(); c != -1; c = zin.read()) {
                    fout.write(c);
                }

                zin.closeEntry();
                fout.close();
            }

        }
        zin.close();
    } catch(Exception e) {
        Log.e("Decompress", "unzip", e);
    }
}
 
開發者ID:csarron,項目名稱:renderscript_examples,代碼行數:27,代碼來源:Unzip.java

示例5: seekToEntry

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
private Optional<ZipEntry> seekToEntry(ZipInputStream inputStream, String entryPath) throws IOException {
    ZipEntry zipEntry;
    while ((zipEntry = inputStream.getNextEntry()) != null) {

        if (zipEntry.getName().startsWith(entryPath)) {
            return Optional.of(zipEntry);
        }
        inputStream.closeEntry();
    }

    return Optional.empty();
}
 
開發者ID:stevesoltys,項目名稱:backup,代碼行數:13,代碼來源:ContentProviderRestoreComponent.java

示例6: doZipUpload

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
private void doZipUpload(final File file)
{
	UploadWorker worker = new UploadWorker(file)
	{
		@Override
		protected String construct(InputStream in) throws Exception
		{
			String agreementName = null;

			ZipEntry entry;
			ZipInputStream zin = new ZipInputStream(in);
			while( (entry = zin.getNextEntry()) != null )
			{
				if( !entry.isDirectory() )
				{
					String name = FOLDER + entry.getName();
					if( name.endsWith(".htm") || name.endsWith(".html") //$NON-NLS-1$ //$NON-NLS-2$
						|| name.endsWith(".xsl") || name.endsWith(".xslt") ) //$NON-NLS-1$ //$NON-NLS-2$
					{
						agreementName = name;
					}

					FileUploader.upload(adminService, stagingId, name, zin);
				}
				zin.closeEntry();
			}

			return agreementName;
		}
	};
	worker.start();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:33,代碼來源:CLAConfigPanel.java

示例7: unZip

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
public static void unZip(File zip, File output) {
    byte[] buffer = new byte[1024];
    try {
        if(!output.exists()) {
            output.mkdirs();
        }
        if(!output.isDirectory()) {
            //System.err.println("\"" + output.getAbsolutePath() + "\" isnt a directory");
            return;
        }
        ZipInputStream zis = new ZipInputStream(new FileInputStream(zip));
        ZipEntry ze = zis.getNextEntry();
        while(ze != null) {
            if(ze.isDirectory()) {
                ze = zis.getNextEntry();
                continue;
            }
            String fileName = ze.getName();
            File newFile = new File(output.getAbsolutePath() + File.separator + fileName);
            //System.out.println("File unzip: " + newFile.getAbsolutePath());
            new File(newFile.getParent()).mkdirs();
            FileOutputStream fos = new FileOutputStream(newFile);
            int len;
            while ((len = zis.read(buffer)) > 0) {
                fos.write(buffer, 0, len);
            }
            fos.close();
            zis.closeEntry();
            ze = zis.getNextEntry();
        }
        zis.close();
    } catch (Exception ex) {
        System.err.println(ex);
    }
}
 
開發者ID:Panzer1119,項目名稱:JAddOn,代碼行數:36,代碼來源:JUtils.java

示例8: process

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
public void process(File file) throws Exception {
	final ZipInputStream zip = new ZipInputStream( new FileInputStream( file ) );

	try {
		ZipEntry entry;
		while ( (entry = zip.getNextEntry()) != null ) {
			final byte[] bytes = ByteCodeHelper.readByteCode( zip );
			entryHandler.handleEntry( entry, bytes );
			zip.closeEntry();
		}
	}
	finally {
		zip.close();
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:16,代碼來源:AbstractInstrumenter.java

示例9: uncompress

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
public static boolean uncompress(File zipFile) {
    boolean success = false;
    try {
        FileInputStream fis = new FileInputStream(zipFile);
        ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
        ZipEntry entry;
        File destFolder = new File(zipFile.getParent(), FileUtils.getNameFromFilename(zipFile.getName()));
        destFolder.mkdirs();
        while ((entry = zis.getNextEntry()) != null) {
            File dest = new File(destFolder, entry.getName());
            dest.getParentFile().mkdirs();

            if(entry.isDirectory()) {
                if (!dest.exists()) {
                    dest.mkdirs();
                }
            } else {
                int size;
                byte[] buffer = new byte[2048];
                FileOutputStream fos = new FileOutputStream(dest);
                BufferedOutputStream bos = new BufferedOutputStream(fos, buffer.length);
                while ((size = zis.read(buffer, 0, buffer.length)) != -1) {
                    bos.write(buffer, 0, size);
                }
                bos.flush();
                bos.close();
                IoUtils.flushQuietly(bos);
                IoUtils.closeQuietly(bos);
            }
            zis.closeEntry();
        }
        IoUtils.closeQuietly(zis);
        IoUtils.closeQuietly(fis);
        success = true;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return success;
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:40,代碼來源:FileUtils.java

示例10: upZipFile

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
public static void upZipFile(Context context,String assetPath,String outputFolderPath){
    File desDir = new File(outputFolderPath);
    if (!desDir.isDirectory()) {
        desDir.mkdirs();
    }
    try {
        InputStream inputStream = context.getResources().getAssets().open(assetPath);
        ZipInputStream zipInputStream=new ZipInputStream(inputStream);
        ZipEntry zipEntry;
        while ((zipEntry = zipInputStream.getNextEntry()) != null) {
            Log.d(TAG, "upZipFile: "+zipEntry.getName());
            if(zipEntry.isDirectory()) {
                File tmpFile=new File(outputFolderPath,zipEntry.getName());
                //Log.d(TAG, "upZipFile: folder "+tmpFile.getAbsolutePath());
                if(!tmpFile.isDirectory())
                    tmpFile.mkdirs();
            } else {
                File desFile = new File(outputFolderPath +"/"+ zipEntry.getName());
                if(desFile.exists()) continue;
                OutputStream out = new FileOutputStream(desFile);
                //Log.d(TAG, "upZipFile: "+desFile.getAbsolutePath());
                byte buffer[] = new byte[1024];
                int realLength;
                while ((realLength = zipInputStream.read(buffer)) > 0) {
                    out.write(buffer, 0, realLength);
                }
                zipInputStream.closeEntry();
                out.close();
            }
        }
        zipInputStream.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:36,代碼來源:FileUtils.java

示例11: writeZip

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
/**
 * Copies the content of a Jar/Zip archive into the receiver archive.
 * <p/>An optional {@link IZipEntryFilter} allows to selectively choose which files
 * to copy over.
 *
 * @param input  the {@link InputStream} for the Jar/Zip to copy.
 * @param filter the filter or <code>null</code>
 * @throws IOException
 */
public void writeZip(InputStream input, IZipEntryFilter filter)
        throws IOException, IZipEntryFilter.ZipAbortException {
    ZipInputStream zis = new ZipInputStream(input);
    try {
        // loop on the entries of the intermediary package and put them in the final package.
        ZipEntry entry;
        while ((entry = zis.getNextEntry()) != null) {
            String name = entry.getName();
            // do not take directories or anything inside a potential META-INF folder.
            if (entry.isDirectory() || name.startsWith("META-INF/")) {
                continue;
            }
            // if we have a filter, we check the entry against it
            if (filter != null && filter.checkEntry(name) == false) {
                continue;
            }
            JarEntry newEntry;
            // Preserve the STORED method of the input entry.
            if (entry.getMethod() == JarEntry.STORED) {
                newEntry = new JarEntry(entry);
            } else {
                // Create a new entry so that the compressed len is recomputed.
                newEntry = new JarEntry(name);
            }
            writeEntry(zis, newEntry);
            zis.closeEntry();
        }
    } finally {
        zis.close();
    }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:41,代碼來源:SignedJarBuilder.java

示例12: unzip

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
/**
 * Extracts a zip file specified by the zipFilePath to a directory specified by
 * destDirectory (will be created if does not exists)
 */
public static void unzip(File file, File destDir) throws IOException
{
   if (!destDir.exists())
   {
      destDir.mkdir();
   }
   ZipInputStream zipIn = new ZipInputStream(new FileInputStream(file));
   ZipEntry entry = zipIn.getNextEntry();
   // iterates over entries in the zip file
   while (entry != null)
   {
      File entryFile = new File(destDir, entry.getName());
      if (!entry.isDirectory())
      {
         // if the entry is a file, extracts it
         extractFile(zipIn, entryFile);
      }
      else
      {
         // if the entry is a directory, make the directory
         entryFile.mkdir();
      }
      zipIn.closeEntry();
      entry = zipIn.getNextEntry();
   }
   zipIn.close();
}
 
開發者ID:forge,項目名稱:springboot-addon,代碼行數:32,代碼來源:UnzipHelper.java

示例13: doZipUpload

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
private void doZipUpload(final File file)
{
	UploadWorker worker = new UploadWorker(file)
	{
		@Override
		protected String construct(InputStream in) throws IOException
		{
			String agreementName = null;

			ZipEntry entry;
			ZipInputStream zin = new ZipInputStream(in);
			while( (entry = zin.getNextEntry()) != null )
			{
				if( !entry.isDirectory() )
				{
					String name = FOLDER + entry.getName();
					if( name.endsWith(".htm") || name.endsWith(".html") //$NON-NLS-1$ //$NON-NLS-2$
						|| name.endsWith(".xsl") || name.endsWith(".xslt") ) //$NON-NLS-1$ //$NON-NLS-2$
					{
						agreementName = name;
					}

					FileUploader.upload(adminService, stagingId, name, zin);
				}
				zin.closeEntry();
			}

			return agreementName;
		}
	};
	worker.start();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:33,代碼來源:CalConfigPanel.java

示例14: uncompress

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
private boolean uncompress(File zipFile) {
    boolean success = false;
    try {
        FileInputStream fis = new FileInputStream(zipFile);
        ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
        ZipEntry entry;
        File destFolder = new File(zipFile.getParent(), FileUtils.getNameFromFilename(zipFile.getName()));
        destFolder.mkdirs();
        while ((entry = zis.getNextEntry()) != null) {
            publishProgress(entry.getName().substring(1));
            publishProgress(""+0);
            File dest = new File(destFolder, entry.getName());
            dest.getParentFile().mkdirs();

            if(entry.isDirectory()) {
                if (!dest.exists()) {
                    dest.mkdirs();
                }
            } else {
                int size;
                byte[] buffer = new byte[2048];
                FileOutputStream fos = new FileOutputStream(dest);
                BufferedOutputStream bos = new BufferedOutputStream(fos, buffer.length);
                long readData=0;
                final long totalFile=entry.getSize();
                while ((size = zis.read(buffer, 0, buffer.length)) != -1) {
                    bos.write(buffer, 0, size);
                    readData+=size;
                    doProgress(readData,totalFile);
                }
                bos.flush();
                bos.close();
                FileUtils.notifyChange(mContex,dest.getAbsolutePath());
            }
            zis.closeEntry();
        }
        success = true;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return success;
}
 
開發者ID:mosamabinomar,項目名稱:RootPGPExplorer,代碼行數:43,代碼來源:CompressTask.java

示例15: doInBackground

import java.util.zip.ZipInputStream; //導入方法依賴的package包/類
@Override
protected Void doInBackground(String... params) {
    try {

        is = new FileInputStream(params[0] + "/" + params[1]);
        zis = new ZipInputStream(new BufferedInputStream(is));
        byte[] buffer = new byte[1024 * 3];
        int count;
        while ((ze = zis.getNextEntry()) != null) {
            filename = ze.getName();
            if (ze.isDirectory()) {
                File fmd = new File(params[0] + "/" + filename);
                fmd.mkdirs();
                continue;
            }

            FileOutputStream fout = new FileOutputStream(params[0] + "/" + filename);
            int total = zis.available();
            while ((count = zis.read(buffer)) != -1) {
                fout.write(buffer, 0, count);
                fileCount++;
                Intent zipedFiles = new Intent(AppConstants.Download.INTENT);
                zipedFiles.putExtra(AppConstants.Download.FILES, context.getString(R.string.extract) + " " + fileCount);
                zipedFiles.putExtra(AppConstants.Download.DOWNLOAD, AppConstants.Download.IN_EXTRACT);
                LocalBroadcastManager.getInstance(context).sendBroadcast(zipedFiles);
            }

            File zipFile = new File(params[0] + "/" + params[1]);
            zipFile.delete();

            if (zipFile.getAbsolutePath().contains("tafseer")) {
                copyFile(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + QuranApplication.getInstance()
                                .getString(R.string.app_folder_path) + "/tafaseer/" + params[1].replace(AppConstants.Extensions.ZIP, AppConstants.Extensions.SQLITE)),
                        new File(params[0] + "/" + params[1].replace(AppConstants.Extensions.ZIP, AppConstants.Extensions.SQLITE)));
            }

            fout.close();
            zis.closeEntry();
        }

        //send broadcast of success or failed
        LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(AppConstants.Download.INTENT)
                .putExtra(AppConstants.Download.DOWNLOAD, AppConstants.Download.SUCCESS ));

        zis.close();
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
    return null;
}
 
開發者ID:fekracomputers,項目名稱:QuranAndroid,代碼行數:52,代碼來源:UnZipping.java


注:本文中的java.util.zip.ZipInputStream.closeEntry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。