public final class XtfFileReader extends Object
Typical usage:
If the curve data is not needed, it is possible to read only the metadata from the disk file. The curve data may be filled in later:XtfFileReader reader = new XtfFileReader(new File("path/to/file.XTF")); XtfFile xtfFile = 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.XtfFileReader reader = new XtfFileReader(new File("path/to/file.XTF")); XtfFile xtfFile = reader.read(false); : reader.readData(xtfFile);
Constructor and Description |
---|
XtfFileReader(File file)
Create a XTF file reader for the specified disk file.
|
XtfFileReader(InputStream inputStream)
Create a XTF file reader for the specified stream.
|
Modifier and Type | Method and Description |
---|---|
static double |
isXtfFile(File file,
byte[] content)
Get the probability that the specified file is an XTF file.
|
XtfFile |
read(boolean shouldReadBulkData)
Read the XTF file from the disk file of this reader.
|
void |
readData(XtfFile xtfFile)
Read curve data from an XTF files where the meta data has
already been read.
|
public XtfFileReader(InputStream inputStream)
inputStream
- Stream to read. Non-null.IllegalArgumentException
- If inputStream is null.public XtfFileReader(File file)
file
- Disk file to read. Non-null.IllegalArgumentException
- If file is null.public static double isXtfFile(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.IllegalArgumentException
- If file is null.public void readData(XtfFile xtfFile) 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 meta data XtfFile xtfFile = reader.read(false); // Read the curve data reader.readData(xtfFile);
// Read meta data XtfFile xtfFile = reader.read(false); // Read mate-data and curve data xtfFile = reader.read(true);
xtfFile
- XTF file to populate with curve data.IllegalArgumentException
- If xtfFile is null.IOException
- If the read operation fails for some reason.public XtfFile 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