当前位置: 首页>>代码示例>>Java>>正文


Java ZipInputStream.available方法代码示例

本文整理汇总了Java中java.util.zip.ZipInputStream.available方法的典型用法代码示例。如果您正苦于以下问题:Java ZipInputStream.available方法的具体用法?Java ZipInputStream.available怎么用?Java ZipInputStream.available使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.zip.ZipInputStream的用法示例。


在下文中一共展示了ZipInputStream.available方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ESRIShapefile

import java.util.zip.ZipInputStream; //导入方法依赖的package包/类
public ESRIShapefile( ZipInputStream zip ) throws IOException {
	filename = null;
	boolean hasDBF = false;
	boolean hasSHP = false;
	ZipEntry entry = zip.getNextEntry();
	while( zip.available()!=0 ) {
		String name = entry.getName();
	System.out.println( name );
		if( name.endsWith(".dbf") || name.endsWith(".shp") ) {
			filename = name.substring( 0, name.lastIndexOf(".") );
		} else if( !name.endsWith(".link") ) {
		//	zip.closeEntry();
			entry = zip.getNextEntry();
			continue;
		}
		int size = (int)entry.getSize();
		byte[] buffer = new byte[size];
		int off = 0;
		int len=size;
		while( (len = zip.read(buffer, off, size-off)) < size-off )off+=len;
		ByteArrayInputStream in = new ByteArrayInputStream(buffer);
		if( name.endsWith(".dbf") ) {
			hasDBF = true;
			dbfFile = new DBFFile( in );
		} else if(name.endsWith(".shp")) {
			shapes = new Vector();
			hasSHP = true;
			readShapes(in);
		} else if(name.endsWith(".link")) {
			readProperties(in);
		}
		entry = zip.getNextEntry();
	//	zip.closeEntry();
	}
	zip.close();
	selected = new Vector();
	initColors();
	if( hasDBF && hasSHP )return;
	else throw new IOException("insufficient information");
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:41,代码来源:ESRIShapefile.java

示例2: 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

示例3: 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;
            long size;
            int iIndex=0;
            while ((ze = zis.getNextEntry()) != null) {
                iIndex++;

                 size = ze.getSize();
                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);
if(iIndex==1) {
    zipedFiles.putExtra(AppConstants.Download.FILES, context.getString(R.string.extract) + " " + fout.getChannel().size()
            + " ( " + (int) (fout.getChannel().size() * 100) / ze.getSize() + "%)");
}else{
    zipedFiles.putExtra(AppConstants.Download.FILES, context.getString(R.string.extract) + " " + iIndex+" off "+"607"
            + " ( " + (int) (iIndex * 100 )/607  + "%)");
}


zipedFiles.putExtra(AppConstants.Download.TYPE , downloadType);
                    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,代码行数:68,代码来源:UnZipping.java


注:本文中的java.util.zip.ZipInputStream.available方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。