zip格式转化成String

</pre><pre name="code" class="java"><pre name="code" class="java"><pre name="code" class="java">public static StringBuffer readZipFile(File file) throws Exception {
		StringBuffer html = new StringBuffer();

		ZipFile zf = new ZipFile(file);
		Enumeration<? extends ZipEntry> zipEntry = zf.entries();
		ZipEntry ze;
		while (zipEntry.hasMoreElements()) {
			ze = zipEntry.nextElement();
			if (ze.isDirectory()) {
				
			} else {
				long size = ze.getSize();
				if (size > 0) {
					BufferedReader br = new BufferedReader(
							new InputStreamReader(zf.getInputStream(ze)));
					String line;
					while ((line = br.readLine()) != null) {
						html.append(line);
					}
					br.close();
				}
			}
		}
		return html;
	}

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券