SSJ
V. 1.2.5.

umontreal.iro.lecuyer.util
Class TextDataReader

java.lang.Object
  extended by umontreal.iro.lecuyer.util.TextDataReader

public class TextDataReader
extends Object

Provides static methods to read data from text files.


Constructor Summary
TextDataReader()
           
 
Method Summary
static double[] readDoubleData(File file)
          Opens the file referred to by the file object file, and calls readDoubleData to obtain an array of double-precision values from the file.
static double[] readDoubleData(Reader input)
          Reads an array of double-precision values from the reader input.
static double[] readDoubleData(String file)
          Opens the file with name file, and calls readDoubleData to obtain an array of double-precision values from the file.
static double[][] readDoubleData2D(File file)
          Opens the file referred to by the file object file, and calls readDoubleData2D to obtain a matrix of double-precision values from the file.
static double[][] readDoubleData2D(Reader input)
          Uses the reader input to obtain a 2-dimensional array of double-precision values.
static double[][] readDoubleData2D(String file)
          Opens the file with name file, and calls readDoubleData2D to obtain a matrix of double-precision values from the file.
static int[] readIntData(File file)
          This is equivalent to readDoubleData, for reading integers.
static int[] readIntData(Reader input)
          This is equivalent to readDoubleData, for reading integers.
static int[] readIntData(String file)
          This is equivalent to readDoubleData, for reading integers.
static int[][] readIntData2D(File file)
          This is equivalent to readDoubleData2D, for reading integers.
static int[][] readIntData2D(Reader input)
          This is equivalent to readDoubleData2D, for reading integers.
static int[][] readIntData2D(String file)
          This is equivalent to readDoubleData2D, for reading integers.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextDataReader

public TextDataReader()
Method Detail

readDoubleData

public static double[] readDoubleData(Reader input)
                               throws IOException
Reads an array of double-precision values from the reader input. For each line of text obtained from the given reader, this method trims whitespaces, and parses the remaining text as a double-precision value. This method ignores every character other than the digits, the plus and minus signs, the period (.), and the letters e and E. Moreover, lines starting with a pound sign (#) are considered as comments and thus skipped. The method returns an array containing all the parsed values.

Parameters:
input - the reader to obtain data from.
Returns:
the obtained array of double-precision values.
Throws:
IOException - if an I/O error occurs.

readDoubleData

public static double[] readDoubleData(File file)
                               throws IOException
Opens the file referred to by the file object file, and calls readDoubleData to obtain an array of double-precision values from the file.

Parameters:
file - the file object representing the file to read.
Returns:
the obtained array of double-precision values.
Throws:
IOException - if an I/O error occurs.

readDoubleData

public static double[] readDoubleData(String file)
                               throws IOException
Opens the file with name file, and calls readDoubleData to obtain an array of double-precision values from the file.

Parameters:
file - the name of the file to read.
Returns:
the obtained array of double-precision values.
Throws:
IOException - if an I/O error occurs.

readIntData

public static int[] readIntData(Reader input)
                         throws IOException
This is equivalent to readDoubleData, for reading integers.

Parameters:
input - the reader to obtain data from.
Returns:
the obtained array of integers.
Throws:
IOException - if an I/O error occurs.

readIntData

public static int[] readIntData(File file)
                         throws IOException
This is equivalent to readDoubleData, for reading integers.

Parameters:
file - the file object represented to file to read.
Returns:
the array of integers.
Throws:
IOException - if an I/O error occurs.

readIntData

public static int[] readIntData(String file)
                         throws IOException
This is equivalent to readDoubleData, for reading integers.

Parameters:
file - the name of the file to read.
Returns:
the array of integers.
Throws:
IOException - if an I/O error occurs.

readDoubleData2D

public static double[][] readDoubleData2D(Reader input)
                                   throws IOException
Uses the reader input to obtain a 2-dimensional array of double-precision values. For each line of text obtained from the given reader, this method trims whitespaces, and parses the remaining text as an array of double-precision values. Every character other than the digits, the plus (+) and minus (-) signs, the period (.), and the letters e and E are ignored and can be used to separate numbers on a line. Moreover, lines starting with a pound sign (#) are considered as comments and thus skipped. The lines containing only a semicolon sign (;) are considered as empty lines. The method returns a 2D array containing all the parsed values. The returned array is not always rectangular.

Parameters:
input - the reader to obtain data from.
Returns:
the 2D array of double-precison values.
Throws:
IOException - if an I/O error occurs.

readDoubleData2D

public static double[][] readDoubleData2D(File file)
                                   throws IOException
Opens the file referred to by the file object file, and calls readDoubleData2D to obtain a matrix of double-precision values from the file.

Parameters:
file - the file object representing the file to read.
Returns:
the obtained matrix of double-precision values.
Throws:
IOException - if an I/O error occurs.

readDoubleData2D

public static double[][] readDoubleData2D(String file)
                                   throws IOException
Opens the file with name file, and calls readDoubleData2D to obtain a matrix of double-precision values from the file.

Parameters:
file - the name of the file to read.
Returns:
the obtained matrix of double-precision values.
Throws:
IOException - if an I/O error occurs.

readIntData2D

public static int[][] readIntData2D(Reader input)
                             throws IOException
This is equivalent to readDoubleData2D, for reading integers.

Parameters:
input - the reader to obtain data from.
Returns:
the obtained 2D array of integers.
Throws:
IOException - if an I/O error occurs.

readIntData2D

public static int[][] readIntData2D(File file)
                             throws IOException
This is equivalent to readDoubleData2D, for reading integers.

Parameters:
file - the file object represented to file to read.
Returns:
the obtain matrix of integer values.
Throws:
IOException - if an I/O error occurs.

readIntData2D

public static int[][] readIntData2D(String file)
                             throws IOException
This is equivalent to readDoubleData2D, for reading integers.

Parameters:
file - the name of the file to read.
Returns:
the obtain matrix of integer values.
Throws:
IOException - if an I/O error occurs.

SSJ
V. 1.2.5.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.