There is a code in which to create a copy of the stream. I have never faced a similar task before.
The fact is that I need to analyze this flow, and only then read it. I post the problem piece of code:
import java.io.*; import java.nio.charset.Charset; import java.util.Scanner; import java.util.jar.JarFile; import java.util.zip.*; public class InputZip{ private ZipEntry entry; private ZipInputStream zipInput; public InputZip(String zipName) throws IOException { zipInput = new ZipInputStream(new FileInputStream(zipName), Charset.defaultCharset()); while ((entry = zipInput.getNextEntry()) != null) { InputStreamReader in = new InputStreamReader(zipInput); InputStreamReader in2 = new InputStreamReader(zipInput); // Бесполезный InputStreamReader in3 = new InputStreamReader(zipInput);// Бесполезный analiz(in); Scanner scan = new Scanner(zipInput); String s = scan.nextLine(); // Исключение! Поток уже использован :( zipInput.closeEntry(); } zipInput.close(); } private void analiz(InputStreamReader b) throws IOException { //Анализ потока (полное прочтение) } }
Need to get a copy of zipInput
.