Class FileInputArrayLoader

java.lang.Object
llnl.gnem.core.util.FileInputArrayLoader

public class FileInputArrayLoader extends Object
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 Details

    • FileInputArrayLoader

      public FileInputArrayLoader()
  • Method Details

    • fillIntsFromFile

      public static int[] fillIntsFromFile(String filename) throws IOException
      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

      public static String[] fillStrings(InputStream stream) throws IOException
      Throws:
      IOException
    • fillStrings

      public static String[] fillStrings(String filename) throws IOException
      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

      public static String[] fillStrings(String filename, boolean discardEmptyLines) throws IOException
      Throws:
      IOException