Here you can find the source of getZipEntryAsString(File archive, String name)
public static String getZipEntryAsString(File archive, String name) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { public static String getZipEntryAsString(File archive, String name) throws IOException { FileInputStream fileIn = null; try {/*from www . j a va 2 s . c o m*/ fileIn = new FileInputStream(archive); BufferedInputStream buffered = new BufferedInputStream(fileIn); ZipInputStream zip = new ZipInputStream(buffered); ArrayList<String> entries = new ArrayList<String>(); ZipEntry next = zip.getNextEntry(); while (next != null) { if (name.equals(next.getName())) { return asString(zip); } entries.add(next.getName()); next = zip.getNextEntry(); } zip.close(); return null; } finally { if (fileIn != null) { fileIn.close(); } } } public static String asString(InputStream inputStream) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder buffer = new StringBuilder(); try { String line = in.readLine(); while (line != null) { buffer.append(line); buffer.append("\n"); line = in.readLine(); } } finally { in.close(); } return buffer.toString(); } }