public final class AscFileReader extends Object
Reader for ASC log data files. ASC is a common term for any column based text file such as CSV etc.
This reader first scans the file to identify the exact format, and can then read as a generic log set.
Constructor and Description |
---|
AscFileReader(File file)
Create an ASC file reader for the specified disk file.
|
AscFileReader(InputStream inputStream)
Create an ASC file reader for the specified stream.
|
Modifier and Type | Method and Description |
---|---|
static double |
isAscFile(File file,
byte[] content)
Get the probability that the specified file is an ASC file.
|
AscFile |
read(boolean shouldReadBulkData)
Read the file and return the associated AscFile instance.
|
void |
readData(AscFile ascFile)
Read data from a ASC file where the meta data has
already been read.
|
public AscFileReader(InputStream inputStream)
inputStream
- Stream to read. Non-null.IllegalArgumentException
- If inputStream is null.public AscFileReader(File file)
file
- Disk file to read. Non-null.IllegalArgumentException
- If file is null.public static double isAscFile(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(AscFile ascFile) throws IOException
// Read meta data AscFile ascFile = reader.read(false); // Read the curve data reader.readData(ascFile);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 AscFile ascFile = reader.read(false); // Read the curve data ascFile = reader.read(true);
ascFile
- The ASC file to populate. This must be the
exact same instance as retrieved by calling the
read(false) on the same AscFileReader instance.
Otherwise the class behavior is unpredictable.IllegalArgumentException
- If ascFile is null.IOException
- If the read operation fails for some reason.public AscFile read(boolean shouldReadBulkData) throws IOException
shouldReadBulkData
- Indicates if bulk log data should be read.
Otherwise, data section will be skipped and left empty.
NOTE: Not currently implemented.IOException
- If the read operation failed for some reason.Copyright © 2024 Petroware AS - https://petroware.no