public class FlamInputStream extends InputStream
This InputStream provides sequential read access to original files. Original files can be normal binary, text or xml data as well as GZIP-, BZIP2-, XZ-, FLAM4-Files or any other kind of original data stream format supported by FLAM. It includes all conversion and formatting capabilities of the Frankenstein Limes Universal Converter (FLUC).
For a more detailed description, please refer to FLAM byte interface (FLCBYT) C API manual.
Constructor and Description |
---|
FlamInputStream(String fileString,
String formatString)
Uses the native FLAM byte interface (written in C) to open a normal
file, a member in a FLAM4FILE, a GZIP file or a member in a concatenated
GZIP-, BZIP- or XZ-File or any other supported file format as an
InputStream.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
String |
close(boolean success,
StatisticFormat statsFormat)
Closes this InputStream and releases any system resources associated
with the stream.
|
String |
getStateString()
When opening a file through the FLAM byte interface, a state string is returned
that contains some metadata about the opened file.
|
static void |
loadLibrary()
Loads the native JNI-based library (flcbytjava) that backs the
functionality of this class.
|
static void |
loadLibrary(String dllPath)
Loads the native JNI-based library that backs the functionality
of this class from the file specified by the path passed as
argument.
|
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
available, mark, markSupported, reset, skip
public FlamInputStream(String fileString, String formatString) throws CharacterCodingException, FlamException
Uses the native FLAM byte interface (written in C) to open a normal file, a member in a FLAM4FILE, a GZIP file or a member in a concatenated GZIP-, BZIP- or XZ-File or any other supported file format as an InputStream. It supports base encoding, encryption, compression, character conversion and text formatting, among others.
This stream class is backed by a native C library (flcbytjava) which must be
loaded prior to calling this constructor by calling either
loadLibrary()
or loadLibrary(String)
. Failing to do so
results in undefined (JVM-dependent) behavior.
The file definition string parameter uses the same syntax as the read method of the FLCL CONV command. The complete syntax and help can be obtained with the corresponding functions below. The string must start with 'read.' followed by the corresponding method (binary/char/text/flam4/xml/...).
Examples:"read.text(file='test.txt')"Please call:
getHelp(HelpSubject.READ_FILE, 10, null) getSyntax(HelpSubject.READ_FILE, 10, null)for more information.
The format string uses the syntax of the 'format' union which was specifically designed for the byte interface to format a byte stream based on the FLAM elements. The string must start with 'format.' followed by the corresponding method.
Examples:"format.text(method=CRLF suptws ccsid='UTF-16LE')" "format.bin()" "format.char(ccsid=DEFAULT)" "format.record(ccsid='IBM-1141')"Please call:
FlamByteInterface.getHelp(HelpSubject.READ_FORMAT, 10, null) FlamByteInterface.getSyntax(HelpSubject.READ_FORMAT, 10, null)for more information.
The file string defines how the FLAM elements are read from to the file. The format string defines how the FLAM elements are converted into a byte stream or records.
fileString
- A file string of the FLCL CONV syntax for read operationsformatString
- A format string specifying the data format of the streamCharacterCodingException
- if converting the parameter strings to the
charset required by the native interface failsFlamException
- if the specified file cannot be openedIllegalArgumentException
- if fileString does not specify a read operation ("read." or "input.")public static void loadLibrary()
FlamByteInterface.loadLibrary()
.FlamByteInterface.loadLibrary()
public static void loadLibrary(String dllPath)
FlamByteInterface.loadLibrary(String)
.dllPath
- Path to the (lib)flybytjava DLLFlamByteInterface.loadLibrary(String)
public int read() throws IOException
read
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
public String close(boolean success, StatisticFormat statsFormat) throws FlamException, CharacterCodingException
Closes this InputStream and releases any system resources associated
with the stream. In contrast to close()
, this method can provide
statistical information.
The 'success' flag allows you to indicate whether the operation using the file was successful from the caller's point-of-view. If you set the 'remove' flag in the file string passed to the constructor, the file is only removed if you indicate success, i.e. pass true for the 'success' parameter. In case of an error while processing the read data, it may be more reasonable to keep the file, even though it was flagged for deletion.
You can also specify the output format for statistics, e.g. a plain list or XML.
success
- True indicates that the data was processed successfully by the callerstatsFormat
- Format of the returned statisticsFlamException
- if an error occurs while closing the fileCharacterCodingException
- if the statistics information string cannot be
converted from the native charset to a Unicode stringclose()
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
public String getStateString()
FlamOutputStream
in order to keep
the metadata that would be lost, otherwise.