Package org.biojava.nbio.core.util
Class InputStreamProvider
- java.lang.Object
-
- org.biojava.nbio.core.util.InputStreamProvider
-
public class InputStreamProvider extends java.lang.ObjectA class that provides an InputStream from a File. The file can be compressed or uncompressed. Currently supported compressions:- Gzip (extension .gz)
- Zip (extension .zip) in this case a stream to the first entry in the zip file is returned
- Jar (extension .jar) same as .Zip; only stream to first entry is returned
- Z (extension .Z) compressed using the unix compress command
- for any other extension, no compression is assumed
- Since:
- 1.5
- Version:
- %I% %G%
- Author:
- Andreas Prlic
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCACHE_PROPERTYstatic intGZIP_MAGICThe magic number found at the start of a GZIP stream.
-
Constructor Summary
Constructors Constructor Description InputStreamProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamgetInputStream(java.io.File f)Get an InputStream for the file.java.io.InputStreamgetInputStream(java.lang.String pathToFile)Get an InputStream for given file path.java.io.InputStreamgetInputStream(java.net.URL u)
-
-
-
Field Detail
-
GZIP_MAGIC
public static final int GZIP_MAGIC
The magic number found at the start of a GZIP stream.- See Also:
- Constant Field Values
-
CACHE_PROPERTY
public static final java.lang.String CACHE_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInputStream
public java.io.InputStream getInputStream(java.lang.String pathToFile) throws java.io.IOExceptionGet an InputStream for given file path. The caller is responsible for closing the stream or otherwise a resource leak can occur.- Parameters:
pathToFile- the path of the file.- Returns:
- an InputStream for the file located at the path.
- Throws:
java.io.IOException
-
getInputStream
public java.io.InputStream getInputStream(java.net.URL u) throws java.io.IOException- Throws:
java.io.IOException
-
getInputStream
public java.io.InputStream getInputStream(java.io.File f) throws java.io.IOExceptionGet an InputStream for the file. The caller is responsible for closing the stream or otherwise a resource leak can occur.- Parameters:
f- a File- Returns:
- an InputStream for the file
- Throws:
java.io.IOException
-
-