Class FileReader
java.lang.Object
org.cloudsimplus.traces.FileReader
- Direct Known Subclasses:
TraceReaderAbstract
Reads and parses data inside text, zip and gzip files.
- Since:
- CloudSim Plus 8.1.0
- Author:
- Manoel Campos da Silva Filho, Anton Beloglazov
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFileReader(@NonNull String filePath) Creates a file reader that considers spaces as field delimiter.FileReader(@NonNull String filePath, int maxLinesToRead) Creates a file reader that considers spaces as field delimiter.FileReader(String fieldDelimiterRegex, @NonNull String filePath) FileReader(String fieldDelimiterRegex, @NonNull String filePath, int maxLinesToRead) Creates a file reader. -
Method Summary
Modifier and TypeMethodDescriptionString[]Gets the Strings that identifies the start of a comment line.static FileReadergetSingleLineReader(@NonNull String filePath) Gets a reader that parses only the first line inside the given file, considering space as the field delimiterString[]readFile()Reads a trace file indicated by the.invalid reference
#getFilePath()protected String[]Reads a trace file indicated by the.invalid reference
#getFilePath()setCommentString(@NonNull String... commentString) Sets Strings that identify the start of a comment line.final FileReadersetMaxLinesToRead(int maxLinesToRead) Sets the maximum number of lines from the workload reader that will be read.
-
Field Details
-
DEF_FIELD_DELIMITER_REGEX
- See Also:
-
-
Constructor Details
-
FileReader
Creates a file reader that considers spaces as field delimiter.- Parameters:
filePath- path of the file to read- See Also:
-
FileReader
-
FileReader
Creates a file reader that considers spaces as field delimiter.- Parameters:
filePath- path of the file to readmaxLinesToRead- The maximum number of lines from the trace reader that will be read.Integer.MAX_VALUEindicates that all lines will be read.- See Also:
-
FileReader
public FileReader(String fieldDelimiterRegex, @NonNull @NonNull String filePath, int maxLinesToRead) Creates a file reader.- Parameters:
fieldDelimiterRegex- A regex defining how fields are delimited in the trace file. Seefor details.invalid reference
#getFieldDelimiterRegex()filePath- path of the file to readmaxLinesToRead- The maximum number of lines from the trace reader that will be read.Integer.MAX_VALUEindicates that all lines will be read.- See Also:
-
-
Method Details
-
getSingleLineReader
Gets a reader that parses only the first line inside the given file, considering space as the field delimiter- Parameters:
filePath- the path of the file to read- Returns:
- the file reader
-
setCommentString
Sets Strings that identify the start of a comment line.- Parameters:
commentString- the comment Strings to set
-
getCommentString
Gets the Strings that identifies the start of a comment line.
For instance ; # % //, according to the file to read. -
setMaxLinesToRead
Sets the maximum number of lines from the workload reader that will be read.Integer.MAX_VALUEindicates that all lines will be read.- Parameters:
maxLinesToRead- the maximum number of lines to set- Returns:
- the file reader
-
readFile
Reads a trace file indicated by the.invalid reference
#getFilePath()- Returns:
- the last parsed line
- Throws:
UncheckedIOException- if there was any error reading the file
-
readFile
Reads a trace file indicated by the. It performs additional processing after parsing the line.invalid reference
#getFilePath()- Parameters:
processParsedLineFunc- aFunctionthat receives each parsed line as an array and performs an operation over it, returning true if the operation was executed- Returns:
- the last parsed line
- Throws:
UncheckedIOException- if there was any error reading the file
-