Here you can find the source of addStringToZip(String text, String entryName, ZipOutputStream zOut)
Parameter | Description |
---|---|
text | a parameter |
entryName | a parameter |
zOut | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static void addStringToZip(String text, String entryName, ZipOutputStream zOut) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class Main { /**// ww w. ja v a 2 s.c om * Adds a String as a field entry to an already opened ZipOutputStream * @param text * @param entryName * @param zOut * @throws IOException */ public static void addStringToZip(String text, String entryName, ZipOutputStream zOut) throws IOException { BufferedReader reader = new BufferedReader(new StringReader(text)); ZipEntry zipEntry = new ZipEntry(entryName); zOut.putNextEntry(zipEntry); int i; while ((i = reader.read()) != -1) { zOut.write(i); } zOut.closeEntry(); } }