Class InputHelper
public class InputHelper
extends java.lang.Object
InputStream
s. In particular, this class contains shortcuts for:
- opening an
InputStream
attached to the standard input using common names like "-" and "stdin" - opening and reading from a compressed file
- attempting to open an
InputStream
and quitting on failure
More generally, there are two types of shortcuts: stream maps and filter maps:
- Stream Maps
- Stream Maps map filenames onto existing
InputStream
s. This feature is designed primarily map the names "-" and "stdin" toSystem.in
(thereby allowing users to enter these names at the command line). However, programmers can use any anyMap<String, InputStream>
. This feature (1) allows users to specify custom names forSystem.in
, and (2) allows the variousopen
methods to easily re-reference existing openInputStreams
. - Filter Maps
- Filter maps map file suffixes onto filter-like
InputStream
s that pre-process the file being opened. (For example, the default filter map maps the suffix 'bz2' ontoCBZip2InputStream
.) Filters are designed primarily to automate the process of opening and decompressing compressed files (bzip2, gzip, etc.). However, they can be used to automate the pre-processing of anyInputStream
based on file suffix.
Note that the open
methods that take File
objects as parameters do not use stream maps.
File
objects are designed to describe specific files. There was little apparent benefit to allowing
File
objects to refer to "virtual" files like "-" and "stdin". In addition, the practice seemed to seemed to
have high potential for confusion. Users who want to use both stream maps and filter maps can simply call the
"filename" version of the method in quesiton and pass it file.getAbsolutePath()
.
Yes, I did go a little overboard with the convenience methods. (Once I added the few I use most, it was trivial to add the rest.)
- Author:
- Zachary Kurmas
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
InputHelper.FilterFactory
Used to wrapInputStreams
with the desired filter. -
Field Summary
Fields Modifier and Type Field Description static InputHelper.FilterFactory
BZIP2_FACTORY
Wraps anInputStream
in aCBZip2InputStream
that uncompresses it.static java.util.Map<java.lang.String,InputHelper.FilterFactory>
DEFAULT_FILTER_FACTORY_MAP
An immutable copy of the map returned bymakeDefaultFilterFactoryMap()
static java.util.Map<java.lang.String,java.io.InputStream>
DEFAULT_INPUT_STREAM_MAP
An immutable copy of the map returned bymakeDefaultInputStreamMap()
-
Method Summary
Modifier and Type Method Description static java.util.Map<java.lang.String,InputHelper.FilterFactory>
makeDefaultFilterFactoryMap()
Generates a map of common file suffixes to appropriateInputHelper.FilterFactory
objects.static java.util.Map<java.lang.String,java.io.InputStream>
makeDefaultInputStreamMap()
Generates a map of common names for the standard input toSystem.in
.static java.io.InputStream
openFilteredInputStream(java.io.File file)
static java.io.InputStream
openFilteredInputStream(java.lang.String filename)
CallsopenInputStream(String, java.util.Map, java.util.Map)
withnull
andDEFAULT_FILTER_FACTORY_MAP
.static java.io.InputStream
openFilteredInputStream(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap)
static java.io.InputStream
openFilteredInputStreamOrQuit(java.io.File file)
CallsopenFilteredInputStream(java.io.File)
and exits if the file can't be opened.static java.io.InputStream
openFilteredInputStreamOrQuit(java.io.File file, java.io.PrintStream error, int exitValue)
CallsopenFilteredInputStream(java.io.File)
and exits if the file can't be opened.static java.io.InputStream
openFilteredInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap)
CallsopenFilteredInputStream(String, java.util.Map)
and exists if the file can't be opened.static java.io.InputStream
openFilteredInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap, java.io.PrintStream error, int exitValue)
CallsopenFilteredInputStream(String, java.util.Map)
and exists if the file can't be opened.static java.io.InputStream
openInputStream(java.io.File file, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)
Opens anInputStream
attached to the specified file using thefilterMap
.static java.io.InputStream
openInputStream(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)
Opens anInputStream
attached to the specified file, usingstreamMap
andfilterMap
.static java.io.InputStream
openInputStreamOrQuit(java.io.File file, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)
CallsopenInputStream(java.io.File, java.util.Map)
and exits if the file can't be opened.static java.io.InputStream
openInputStreamOrQuit(java.io.File file, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap, java.io.PrintStream error, int exitValue)
CallsopenInputStream(java.io.File, java.util.Map)
and exits if the file can't be opened.static java.io.InputStream
openInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)
CallsopenInputStream(String, java.util.Map, java.util.Map)
and exits if the file can't be opened.static java.io.InputStream
openInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap, java.io.PrintStream error, int exitValue)
CallsopenInputStream(String, java.util.Map, java.util.Map)
and exits if the file can't be opened.static java.io.InputStream
openMappedAndFilteredInputStream(java.lang.String filename)
static java.io.InputStream
openMappedAndFilteredInputStreamOrQuit(java.lang.String filename)
CallsopenInputStream(String, java.util.Map, java.util.Map)
withDEFAULT_INPUT_STREAM_MAP
andDEFAULT_FILTER_FACTORY_MAP
and exists if the file can't be opened.static java.io.InputStream
openMappedAndFilteredInputStreamOrQuit(java.lang.String filename, java.io.PrintStream error, int exitValue)
CallsopenInputStream(String, java.util.Map, java.util.Map)
withDEFAULT_INPUT_STREAM_MAP
andDEFAULT_FILTER_FACTORY_MAP
and exists if the file can't be opened.static java.io.InputStream
openMappedInputStream(java.lang.String filename)
static java.io.InputStream
openMappedInputStream(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)
static java.io.InputStream
openMappedInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)
CallsopenMappedInputStream(String, java.util.Map)
and exists if the file can't be opened.static java.io.InputStream
openMappedInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap, java.io.PrintStream error, int exitValue)
CallsopenMappedInputStream(String, java.util.Map)
and exists if the file can't be opened.static java.io.InputStream
openUnfilteredInputStream(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap)
CallsopenInputStream(String, java.util.Map, java.util.Map)
withnull
.static java.io.InputStream
openUnfilteredInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap)
CallsopenUnfilteredInputStream(String, java.util.Map)
and exists if the file can't be opened.static java.io.InputStream
openUnfilteredInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap, java.io.PrintStream error, int exitValue)
CallsopenUnfilteredInputStream(String, java.util.Map)
and exists if the file can't be opened.static java.io.InputStream
openUnmappedInputStream(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)
CallsopenInputStream(String, java.util.Map, java.util.Map)
withnull
.static java.io.InputStream
openUnmappedInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)
CallsopenUnmappedInputStream(String, java.util.Map)
and exists if the file can't be opened.static java.io.InputStream
openUnmappedInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap, java.io.PrintStream error, int exitValue)
CallsopenUnmappedInputStream(String, java.util.Map)
and exists if the file can't be opened.
-
Field Details
-
DEFAULT_INPUT_STREAM_MAP
public static final java.util.Map<java.lang.String,java.io.InputStream> DEFAULT_INPUT_STREAM_MAPAn immutable copy of the map returned bymakeDefaultInputStreamMap()
-
BZIP2_FACTORY
Wraps anInputStream
in aCBZip2InputStream
that uncompresses it. -
DEFAULT_FILTER_FACTORY_MAP
public static final java.util.Map<java.lang.String,InputHelper.FilterFactory> DEFAULT_FILTER_FACTORY_MAPAn immutable copy of the map returned bymakeDefaultFilterFactoryMap()
-
-
Method Details
-
makeDefaultInputStreamMap
public static java.util.Map<java.lang.String,java.io.InputStream> makeDefaultInputStreamMap()Generates a map of common names for the standard input toSystem.in
.- Returns:
- the map
-
makeDefaultFilterFactoryMap
public static java.util.Map<java.lang.String,InputHelper.FilterFactory> makeDefaultFilterFactoryMap()Generates a map of common file suffixes to appropriateInputHelper.FilterFactory
objects. For example, the default map maps "bz2" to aFilterFactory
that builds aCBZip2InputStream
.- Returns:
- a map of common suffixes to appropriate
InputHelper.FilterFactory
objects.
-
openInputStream
public static java.io.InputStream openInputStream(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap) throws java.io.FileNotFoundExceptionOpens anInputStream
attached to the specified file, usingstreamMap
andfilterMap
. Specifically,- If
filename
appears instreamMap
, then return thatInputSteam
. - If
filename
's suffix appears infilterMap
, then apply thatFilterFactory
. - If neither condition above applies, then return a new
InputStream
attached to the specified file .
Note:
InputStreams
found instreamMap
are not affected by thefilterMap
— even if there is an entry infilterMap
forfilename
's suffix. It is assumed that theInputStream
s in thestreamMap
will already be configured with any desired filtering/pre-processing.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).streamMap
- a map of file names to existingInputStream
sfilterMap
- a map of file suffixes to filters that will pre-process the file.- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
. - Throws:
java.io.FileNotFoundException
- if the requested file does not exist.InputHelper.FilterFactory.FilterFactoryException
- if the specified filter cannot handle the given file.
- If
-
openMappedAndFilteredInputStream
public static java.io.InputStream openMappedAndFilteredInputStream(java.lang.String filename) throws java.io.FileNotFoundExceptionCallsopenInputStream(String, java.util.Map, java.util.Map)
withDEFAULT_INPUT_STREAM_MAP
andDEFAULT_FILTER_FACTORY_MAP
.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
. - Throws:
java.io.FileNotFoundException
- if the requested file does not exist.InputHelper.FilterFactory.FilterFactoryException
- if the specified filter cannot handle the given file.
-
openFilteredInputStream
public static java.io.InputStream openFilteredInputStream(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap) throws java.io.FileNotFoundException- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).streamMap
- a map of file names to existingInputStream
s- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
. - Throws:
java.io.FileNotFoundException
- if the requested file does not exist.InputHelper.FilterFactory.FilterFactoryException
- if the specified filter cannot handle the given file.
-
openFilteredInputStream
public static java.io.InputStream openFilteredInputStream(java.lang.String filename) throws java.io.FileNotFoundExceptionCallsopenInputStream(String, java.util.Map, java.util.Map)
withnull
andDEFAULT_FILTER_FACTORY_MAP
.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
. - Throws:
java.io.FileNotFoundException
- if the requested file does not exist.InputHelper.FilterFactory.FilterFactoryException
- if the specified filter cannot handle the given file.
-
openUnfilteredInputStream
public static java.io.InputStream openUnfilteredInputStream(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap) throws java.io.FileNotFoundExceptionCallsopenInputStream(String, java.util.Map, java.util.Map)
withnull
.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).streamMap
- a map of file names to existingInputStream
s- Returns:
- either the
InputStream
instreamMap
, or a newInputStream
. - Throws:
java.io.FileNotFoundException
- if the requested file does not exist.InputHelper.FilterFactory.FilterFactoryException
- if the specified filter cannot handle the given file.
-
openMappedInputStream
public static java.io.InputStream openMappedInputStream(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap) throws java.io.FileNotFoundException- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).filterMap
- a map of file suffixes to filters that will pre-process the file.- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
. - Throws:
java.io.FileNotFoundException
- if the requested file does not exist.InputHelper.FilterFactory.FilterFactoryException
- if the specified filter cannot handle the given file.
-
openMappedInputStream
public static java.io.InputStream openMappedInputStream(java.lang.String filename) throws java.io.FileNotFoundException- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
. - Throws:
java.io.FileNotFoundException
- if the requested file does not exist.InputHelper.FilterFactory.FilterFactoryException
- if the specified filter cannot handle the given file.
-
openUnmappedInputStream
public static java.io.InputStream openUnmappedInputStream(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap) throws java.io.FileNotFoundExceptionCallsopenInputStream(String, java.util.Map, java.util.Map)
withnull
.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).filterMap
- a map of file suffixes to filters that will pre-process the file.- Returns:
- a new, possibly filtered,
InputStream
. - Throws:
java.io.FileNotFoundException
- if the requested file does not exist.InputHelper.FilterFactory.FilterFactoryException
- if the specified filter cannot handle the given file.
-
openInputStream
public static java.io.InputStream openInputStream(java.io.File file, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap) throws java.io.FileNotFoundExceptionOpens anInputStream
attached to the specified file using thefilterMap
. Specifically, if thefile
's suffix appears infilterMap
, then apply thatFilterFactory
, otherwise, return a newInputStream
attached to the specified file- Parameters:
file
- the name of the file to openfilterMap
- a map of file suffixes to filters that will pre-process the file.- Returns:
- a new, possibly filtered,
InputStream
. - Throws:
java.io.FileNotFoundException
- if the file cannot be opened.InputHelper.FilterFactory.FilterFactoryException
- if the specified filter cannot handle the given file.
-
openFilteredInputStream
public static java.io.InputStream openFilteredInputStream(java.io.File file) throws java.io.FileNotFoundException- Parameters:
file
- the file to open- Returns:
- a new, possibly filtered,
InputStream
. - Throws:
java.io.FileNotFoundException
- if the file cannot be opened.InputHelper.FilterFactory.FilterFactoryException
- if the specified filter cannot handle the given file.
-
openInputStreamOrQuit
public static java.io.InputStream openInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap, java.io.PrintStream error, int exitValue)CallsopenInputStream(String, java.util.Map, java.util.Map)
and exits if the file can't be opened.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).streamMap
- a map of file names to existingInputStream
sfilterMap
- a map of file suffixes to filters that will pre-process the file.error
- thePrintStream
to which to write any errors.exitValue
- the value to pass toSystem.exit
in the event of an error- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
.
-
openInputStreamOrQuit
public static java.io.InputStream openInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)CallsopenInputStream(String, java.util.Map, java.util.Map)
and exits if the file can't be opened.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).streamMap
- a map of file names to existingInputStream
sfilterMap
- a map of file suffixes to filters that will pre-process the file.- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
.
-
openMappedAndFilteredInputStreamOrQuit
public static java.io.InputStream openMappedAndFilteredInputStreamOrQuit(java.lang.String filename, java.io.PrintStream error, int exitValue)CallsopenInputStream(String, java.util.Map, java.util.Map)
withDEFAULT_INPUT_STREAM_MAP
andDEFAULT_FILTER_FACTORY_MAP
and exists if the file can't be opened.- Parameters:
error
- thePrintStream
to which to write any errors.exitValue
- the value to pass toSystem.exit
in the event of an errorfilename
- the name of the file to open (or one of the keys instreamMap
).- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
.
-
openMappedAndFilteredInputStreamOrQuit
public static java.io.InputStream openMappedAndFilteredInputStreamOrQuit(java.lang.String filename)CallsopenInputStream(String, java.util.Map, java.util.Map)
withDEFAULT_INPUT_STREAM_MAP
andDEFAULT_FILTER_FACTORY_MAP
and exists if the file can't be opened.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
.
-
openFilteredInputStreamOrQuit
public static java.io.InputStream openFilteredInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap, java.io.PrintStream error, int exitValue)CallsopenFilteredInputStream(String, java.util.Map)
and exists if the file can't be opened.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).streamMap
- a map of file names to existingInputStream
serror
- thePrintStream
to which to write any errors.exitValue
- the value to pass toSystem.exit
in the event of an error- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
.
-
openFilteredInputStreamOrQuit
public static java.io.InputStream openFilteredInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap)CallsopenFilteredInputStream(String, java.util.Map)
and exists if the file can't be opened.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).streamMap
- a map of file names to existingInputStream
s- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
.
-
openUnfilteredInputStreamOrQuit
public static java.io.InputStream openUnfilteredInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap, java.io.PrintStream error, int exitValue)CallsopenUnfilteredInputStream(String, java.util.Map)
and exists if the file can't be opened.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).streamMap
- a map of file names to existingInputStream
serror
- thePrintStream
to which to write any errors.exitValue
- the value to pass toSystem.exit
in the event of an error- Returns:
- either the
InputStream
instreamMap
, or a newInputStream
.
-
openUnfilteredInputStreamOrQuit
public static java.io.InputStream openUnfilteredInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,java.io.InputStream> streamMap)CallsopenUnfilteredInputStream(String, java.util.Map)
and exists if the file can't be opened.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).streamMap
- a map of file names to existingInputStream
s- Returns:
- either the
InputStream
instreamMap
, or a newInputStream
.
-
openMappedInputStreamOrQuit
public static java.io.InputStream openMappedInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap, java.io.PrintStream error, int exitValue)CallsopenMappedInputStream(String, java.util.Map)
and exists if the file can't be opened.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).filterMap
- a map of file suffixes to filters that will pre-process the file.error
- thePrintStream
to which to write any errors.exitValue
- the value to pass toSystem.exit
in the event of an error- Returns:
- either the
InputStream
in the default stream map or a new, possibly filtered,InputStream
.
-
openMappedInputStreamOrQuit
public static java.io.InputStream openMappedInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)CallsopenMappedInputStream(String, java.util.Map)
and exists if the file can't be opened.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).filterMap
- a map of file suffixes to filters that will pre-process the file.- Returns:
- either the
InputStream
in the default stream map or a new, possibly filtered,InputStream
.
-
openUnmappedInputStreamOrQuit
public static java.io.InputStream openUnmappedInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap, java.io.PrintStream error, int exitValue)CallsopenUnmappedInputStream(String, java.util.Map)
and exists if the file can't be opened.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).filterMap
- a map of file suffixes to filters that will pre-process the file.error
- thePrintStream
to which to write any errors.exitValue
- the value to pass toSystem.exit
in the event of an error- Returns:
- a new, possibly filtered,
InputStream
.
-
openUnmappedInputStreamOrQuit
public static java.io.InputStream openUnmappedInputStreamOrQuit(java.lang.String filename, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)CallsopenUnmappedInputStream(String, java.util.Map)
and exists if the file can't be opened.- Parameters:
filename
- the name of the file to open (or one of the keys instreamMap
).filterMap
- a map of file suffixes to filters that will pre-process the file.- Returns:
- a new, possibly filtered,
InputStream
.
-
openInputStreamOrQuit
public static java.io.InputStream openInputStreamOrQuit(java.io.File file, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap, java.io.PrintStream error, int exitValue)CallsopenInputStream(java.io.File, java.util.Map)
and exits if the file can't be opened.- Parameters:
file
- thefile
to open (or one of the keys instreamMap
).filterMap
- a map of file suffixes to filters that will pre-process the file.error
- thePrintStream
to which to write any errors.exitValue
- the value to pass toSystem.exit
in the event of an error- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
.
-
openInputStreamOrQuit
public static java.io.InputStream openInputStreamOrQuit(java.io.File file, java.util.Map<java.lang.String,InputHelper.FilterFactory> filterMap)CallsopenInputStream(java.io.File, java.util.Map)
and exits if the file can't be opened.- Parameters:
file
- thefile
to open (or one of the keys instreamMap
).filterMap
- a map of file suffixes to filters that will pre-process the file.- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
.
-
openFilteredInputStreamOrQuit
public static java.io.InputStream openFilteredInputStreamOrQuit(java.io.File file, java.io.PrintStream error, int exitValue)CallsopenFilteredInputStream(java.io.File)
and exits if the file can't be opened.- Parameters:
file
- thefile
to open (or one of the keys instreamMap
).error
- thePrintStream
to which to write any errors.exitValue
- the value to pass toSystem.exit
in the event of an error- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
.
-
openFilteredInputStreamOrQuit
public static java.io.InputStream openFilteredInputStreamOrQuit(java.io.File file)CallsopenFilteredInputStream(java.io.File)
and exits if the file can't be opened.- Parameters:
file
- thefile
to open (or one of the keys instreamMap
).- Returns:
- either the
InputStream
instreamMap
, or a new, possibly filtered,InputStream
.
-