Package org.refcodes.io
Class ZipFileOutputStreamImpl
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- java.io.BufferedOutputStream
-
- org.refcodes.io.ZipFileOutputStreamImpl
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class ZipFileOutputStreamImpl extends BufferedOutputStream
Represents anOutputStream
to a providedFile
: In case the file points to a ZIP compressed file, then a therein to be contained file with the same name excluding the ".zip" extension is created by theOutputStream
.
-
-
Field Summary
-
Fields inherited from class java.io.BufferedOutputStream
buf, count
-
Fields inherited from class java.io.FilterOutputStream
out
-
-
Constructor Summary
Constructors Constructor Description ZipFileOutputStreamImpl(File aFile)
Instantiates a new zip file output stream impl.ZipFileOutputStreamImpl(File parent, String child)
Instantiates a new zip file output stream impl.ZipFileOutputStreamImpl(String pathname)
Instantiates a new zip file output stream impl.ZipFileOutputStreamImpl(String parent, String child)
Instantiates a new zip file output stream impl.ZipFileOutputStreamImpl(URI uri)
Instantiates a new zip file output stream impl.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static String
toFileNameFromZip(String aZipFileName)
To file name from zip.protected static OutputStream
toOutputStream(File aFile)
Returns anOutputStream
to the providedFile
.-
Methods inherited from class java.io.BufferedOutputStream
flush, write, write
-
Methods inherited from class java.io.FilterOutputStream
close, write
-
-
-
-
Constructor Detail
-
ZipFileOutputStreamImpl
public ZipFileOutputStreamImpl(File parent, String child) throws ZipException, FileNotFoundException, IOException
Instantiates a new zip file output stream impl.- Parameters:
parent
- the parentchild
- the child- Throws:
ZipException
- the zip exceptionFileNotFoundException
- the file not found exceptionIOException
- Signals that an I/O exception has occurred.
-
ZipFileOutputStreamImpl
public ZipFileOutputStreamImpl(String parent, String child) throws ZipException, FileNotFoundException, IOException
Instantiates a new zip file output stream impl.- Parameters:
parent
- the parentchild
- the child- Throws:
ZipException
- the zip exceptionFileNotFoundException
- the file not found exceptionIOException
- Signals that an I/O exception has occurred.
-
ZipFileOutputStreamImpl
public ZipFileOutputStreamImpl(String pathname) throws ZipException, FileNotFoundException, IOException
Instantiates a new zip file output stream impl.- Parameters:
pathname
- the pathname- Throws:
ZipException
- the zip exceptionFileNotFoundException
- the file not found exceptionIOException
- Signals that an I/O exception has occurred.
-
ZipFileOutputStreamImpl
public ZipFileOutputStreamImpl(URI uri) throws ZipException, FileNotFoundException, IOException
Instantiates a new zip file output stream impl.- Parameters:
uri
- the uri- Throws:
ZipException
- the zip exceptionFileNotFoundException
- the file not found exceptionIOException
- Signals that an I/O exception has occurred.
-
ZipFileOutputStreamImpl
public ZipFileOutputStreamImpl(File aFile) throws ZipException, FileNotFoundException, IOException
Instantiates a new zip file output stream impl.- Parameters:
aFile
- the file- Throws:
ZipException
- the zip exceptionFileNotFoundException
- the file not found exceptionIOException
- Signals that an I/O exception has occurred.
-
-
Method Detail
-
toOutputStream
protected static OutputStream toOutputStream(File aFile) throws ZipException, IOException, FileNotFoundException
Returns anOutputStream
to the providedFile
. In case the file points to a ZIP compressed file (it has the file suffix ".zip"), then the data written to theOutputStream
is being ZIP compressed.- Parameters:
aFile
- TheFile
for which to get theOutputStream
.- Returns:
- An
OutputStream
, in case of a ZIP compressedFile
was specified (with suffix ".zip"), then a compressedOutputStream
is returned. - Throws:
ZipException
- in case there were problems when accessing the ZIP compressedFile
.IOException
- in case there were problems working with theFile
.FileNotFoundException
- in case there was none suchFile
found.
-
toFileNameFromZip
protected static String toFileNameFromZip(String aZipFileName)
To file name from zip.- Parameters:
aZipFileName
- the zip file name- Returns:
- the string
- See Also:
ZipFileInputStreamImpl.toFileNameFromZip(String)
-
-