Last active
January 4, 2016 13:49
-
-
Save alexproca/8630158 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.io.InputStream; | |
import java.util.zip.ZipInputStream; | |
/** | |
* This class is a wrapper for ZipInputStream. | |
* If you try to put ZipInputStream in a InputStreamReader you will get | |
* an error because when close() is called the whole ZipInputStream will | |
* be closed. For reading only a part from the stream corresponding to a | |
* ZipEntry, instead of calling stream.close() you should call stream.closeEntry() | |
* | |
* @author Alex Proca | |
* | |
*/ | |
public class ZipEntryInputStream extends InputStream { | |
private ZipInputStream stream; | |
public ZipInputStreamWrapper(ZipInputStream stream) | |
{ | |
this.stream = stream; | |
} | |
public int read() throws IOException | |
{ | |
return stream.read(); | |
} | |
public void close() throws IOException | |
{ | |
stream.closeEntry(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment