public final class BitFileReader extends Object
Typical usage:
If the curve data is not needed, it is possible to read only the metadata from the source. The curve data may be filled in later:BitFileReader reader = new BitFileReader(new File("path/to/file.BIT")); List<BitFile> bitFiles = reader.read(true);
Note that even if only metadata is read, all sub-files and curve information are properly established as this information comes from metadata. Only the curve values will be missing.BitFileReader reader = new BitFileReader(new File("path/to/file.BIT")); List<BitFile> bitFiles = reader.read(false); reader.readData(bitFiles);
Constructor and Description |
---|
BitFileReader(File file)
Create a BIT file reader for the specified disk file.
|
BitFileReader(InputStream inputStream)
Create a BIT reader for the specified stream.
|
Modifier and Type | Method and Description |
---|---|
static double |
isBitFile(File file,
byte[] content)
Get the probability that the specified file is a BIT file.
|
List<BitFile> |
read(boolean shouldReadBulkData)
Read all BIT files from the stream.
|
void |
readData(List<BitFile> bitFiles)
Read data from a set of BIT files where the metadata has
already been read.
|
public BitFileReader(InputStream inputStream)
inputStream
- Stream to read. Non-null.IllegalArgumentException
- If inputStream is null.public BitFileReader(File file)
file
- Disk file to read. Non-null.IllegalArgumentException
- If file is null.public static double isBitFile(File file, byte[] content)
The check can be done with or without considering the content of the file. In the latter case, only the file name (typically its extension) is considered. In the former case a portion from the start of the file is used to match for known patterns. By passing the portion as an argument, the client code can read this once and then pass it to different classifiers in order to determine its most likely type.
Getting a portion of a file can be done by:
File file = ...; BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file)); byte[] content = new byte[2000]; stream.read(content, 0, content.length); stream.close();
file
- File to check. Null to classify on content only.content
- A number of bytes from the start of the file.
Null to classify on file name only.public void readData(List<BitFile> bitFiles) throws IOException
There is nothing to gain in performance with this approach so in case the result is not cached, the following will be equivalent:// Read metadata List<BitFile> bitFiles = reader.read(false); // Read the curve data reader.readData(bitFiles);
// Read metadata List<BitFile> bitFiles = reader.read(false); // Read the curve data bitFiles = reader.read(true);
bitFiles
- BIT files to populate with curve data.IllegalArgumentException
- If bitFiles is null.IOException
- If the read operation fails for some reason.public List<BitFile> read(boolean shouldReadBulkData) throws IOException
shouldReadBulkData
- Indicate if bulk data should be read. False
to read header information only.IOException
- If the read operation fails for some reason.Copyright © 2024 Petroware AS - https://petroware.no