Package llnl.gnem.core.util
Class FileInputArrayLoader
java.lang.Object
llnl.gnem.core.util.FileInputArrayLoader
A class that provides utility methods for loading arrays of primitive types
for files. Files are assumed to have one value per line and to have no
extraneous lines ( comments etc. ).
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[]
fillIntsFromFile
(String filename) Read the specified text file and return an array of ints with one element per line in the file.static String[]
fillStrings
(InputStream stream) static String[]
fillStrings
(String filename) Read the specified text file and return an array of Strings with one element per line in the file.static String[]
fillStrings
(String filename, boolean discardEmptyLines)
-
Constructor Details
-
FileInputArrayLoader
public FileInputArrayLoader()
-
-
Method Details
-
fillIntsFromFile
Read the specified text file and return an array of ints with one element per line in the file. The file is assumed to have one int value per line and no empty lines or lines with characters not interpretable as an int.- Parameters:
filename
- The name of the file to be read.- Returns:
- The array of ints read from the file.
- Throws:
IOException
- Exception thrown if there is an error reading the file.
-
fillStrings
- Throws:
IOException
-
fillStrings
Read the specified text file and return an array of Strings with one element per line in the file.- Parameters:
filename
- The name of the file to be read.- Returns:
- The array of Strings read from the file.
- Throws:
IOException
- Exception thrown if there is an error reading the file.
-
fillStrings
- Throws:
IOException
-