SSJ  3.3.1
Stochastic Simulation in Java
Static Public Member Functions | List of all members
TextDataReader Class Reference

Provides static methods to read data from text files. More...

Static Public Member Functions

static double [] readDoubleData (Reader input) throws IOException
 Reads an array of double-precision values from the reader input. More...
 
static double [] readDoubleData (URL url) throws IOException
 Connects to the URL referred to by the URL object url, and calls readDoubleData(Reader) to obtain an array of double-precision values from the resource. More...
 
static double [] readDoubleData (File file) throws IOException
 Opens the file referred to by the file object file, and calls readDoubleData(Reader) to obtain an array of double-precision values from the file. More...
 
static double [] readDoubleData (String file) throws IOException
 Opens the file with name file, and calls readDoubleData(Reader) to obtain an array of double-precision values from the file. More...
 
static int [] readIntData (Reader input) throws IOException
 This is equivalent to readDoubleData(Reader), for reading integers. More...
 
static int [] readIntData (URL url) throws IOException
 Connects to the URL referred to by the URL object url, and calls readIntData(Reader) to obtain an array of integers from the resource. More...
 
static int [] readIntData (File file) throws IOException
 This is equivalent to readDoubleData(File), for reading integers. More...
 
static int [] readIntData (String file) throws IOException
 This is equivalent to readDoubleData(String), for reading integers. More...
 
static String [] readStringData (Reader input) throws IOException
 Reads an array of strings from the reader input. More...
 
static String [] readStringData (URL url) throws IOException
 Connects to the URL referred to by the URL object url, and calls readStringData(Reader) to obtain an array of integers from the resource. More...
 
static String [] readStringData (File file) throws IOException
 This is equivalent to readDoubleData(File), for reading strings. More...
 
static String [] readStringData (String file) throws IOException
 This is equivalent to readDoubleData(String), for reading strings. More...
 
static double [][] readDoubleData2D (Reader input) throws IOException
 Uses the reader input to obtain a 2-dimensional array of double-precision values. More...
 
static double [][] readDoubleData2D (URL url) throws IOException
 Connects to the URL referred to by the URL object url, and calls readDoubleData2D(Reader) to obtain a matrix of double-precision values from the resource. More...
 
static double [][] readDoubleData2D (File file) throws IOException
 Opens the file referred to by the file object file, and calls readDoubleData2D(Reader) to obtain a matrix of double-precision values from the file. More...
 
static double [][] readDoubleData2D (String file) throws IOException
 Opens the file with name file, and calls readDoubleData2D(Reader) to obtain a matrix of double-precision values from the file. More...
 
static int [][] readIntData2D (Reader input) throws IOException
 This is equivalent to readDoubleData2D(Reader), for reading integers. More...
 
static int [][] readIntData2D (URL url) throws IOException
 Connects to the URL referred to by the URL object url, and calls readDoubleData(Reader) to obtain a matrix of integers from the resource. More...
 
static int [][] readIntData2D (File file) throws IOException
 This is equivalent to readDoubleData2D(File), for reading integers. More...
 
static int [][] readIntData2D (String file) throws IOException
 This is equivalent to readDoubleData2D(String), for reading integers. More...
 
static String [][] readCSVData (Reader input, char colDelim, char stringDelim) throws IOException
 Reads comma-separated values (CSV) from reader input, and returns a 2D array of strings corresponding to the read data. More...
 
static String [][] readCSVData (URL url, char colDelim, char stringDelim) throws IOException
 Connects to the URL referred to by the URL object url, and calls readCSVData(Reader,char,char) to obtain a matrix of strings from the resource. More...
 
static String [][] readCSVData (File file, char colDelim, char stringDelim) throws IOException
 This is equivalent to readDoubleData2D(File), for reading strings. More...
 
static String [][] readCSVData (String file, char colDelim, char stringDelim) throws IOException
 This is equivalent to readDoubleData2D(String), for reading strings. More...
 

Detailed Description

Provides static methods to read data from text files.

Member Function Documentation

◆ readCSVData() [1/4]

static String [][] readCSVData ( Reader  input,
char  colDelim,
char  stringDelim 
) throws IOException
static

Reads comma-separated values (CSV) from reader input, and returns a 2D array of strings corresponding to the read data.

Lines are delimited using line separators \r, \n, and \r\n. Each line contains one or more values, separated by the column delimiter colDelim. If a string of characters is surrounded with the string delimiter stringDelim, any line separator and column separator appear in the string. The string delimiter can be inserted in such a string by putting it twice. Usually, the column delimiter is the comma, and the string delimiter is the quotation mark. The following example uses these default delimiters.

         "One","Two","Three"
          1,2,3
         "String with "" delimiter",n,m

This produces a matrix of strings with dimensions \(3\times3\). The first row contains the strings One, Two, and Three while the second row contains the strings 1, 2, and 3. The first column of the last row contains the string String with " delimiter.

Parameters
inputthe reader to obtain data from.
colDelimthe column delimiter.
stringDelimthe string delimiter.
Returns
the obtained 2D array of strings.
Exceptions
IOExceptionif an I/O error occurs.

◆ readCSVData() [2/4]

static String [][] readCSVData ( URL  url,
char  colDelim,
char  stringDelim 
) throws IOException
static

Connects to the URL referred to by the URL object url, and calls readCSVData(Reader,char,char) to obtain a matrix of strings from the resource.

Parameters
urlthe URL object representing the resource to read.
colDelimthe column delimiter.
stringDelimthe string delimiter.
Returns
the obtained matrix of strings.
Exceptions
IOExceptionif an I/O error occurs.

◆ readCSVData() [3/4]

static String [][] readCSVData ( File  file,
char  colDelim,
char  stringDelim 
) throws IOException
static

This is equivalent to readDoubleData2D(File), for reading strings.

Parameters
filethe file object represented to file to read.
colDelimthe column delimiter.
stringDelimthe string delimiter.
Returns
the obtained matrix of string values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readCSVData() [4/4]

static String [][] readCSVData ( String  file,
char  colDelim,
char  stringDelim 
) throws IOException
static

This is equivalent to readDoubleData2D(String), for reading strings.

Parameters
filethe name of the file to read.
colDelimthe column delimiter.
stringDelimthe string delimiter.
Returns
the obtained matrix of string values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readDoubleData() [1/4]

static double [] readDoubleData ( Reader  input) throws IOException
static

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
inputthe reader to obtain data from.
Returns
the obtained array of double-precision values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readDoubleData() [2/4]

static double [] readDoubleData ( URL  url) throws IOException
static

Connects to the URL referred to by the URL object url, and calls readDoubleData(Reader) to obtain an array of double-precision values from the resource.

Parameters
urlthe URL object representing the resource to read.
Returns
the obtained array of double-precision values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readDoubleData() [3/4]

static double [] readDoubleData ( File  file) throws IOException
static

Opens the file referred to by the file object file, and calls readDoubleData(Reader) to obtain an array of double-precision values from the file.

Parameters
filethe file object representing the file to read.
Returns
the obtained array of double-precision values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readDoubleData() [4/4]

static double [] readDoubleData ( String  file) throws IOException
static

Opens the file with name file, and calls readDoubleData(Reader) to obtain an array of double-precision values from the file.

Parameters
filethe name of the file to read.
Returns
the obtained array of double-precision values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readDoubleData2D() [1/4]

static double [][] readDoubleData2D ( Reader  input) throws IOException
static

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
inputthe reader to obtain data from.
Returns
the 2D array of double-precison values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readDoubleData2D() [2/4]

static double [][] readDoubleData2D ( URL  url) throws IOException
static

Connects to the URL referred to by the URL object url, and calls readDoubleData2D(Reader) to obtain a matrix of double-precision values from the resource.

Parameters
urlthe URL object representing the resource to read.
Returns
the obtained matrix of double-precision values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readDoubleData2D() [3/4]

static double [][] readDoubleData2D ( File  file) throws IOException
static

Opens the file referred to by the file object file, and calls readDoubleData2D(Reader) to obtain a matrix of double-precision values from the file.

Parameters
filethe file object representing the file to read.
Returns
the obtained matrix of double-precision values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readDoubleData2D() [4/4]

static double [][] readDoubleData2D ( String  file) throws IOException
static

Opens the file with name file, and calls readDoubleData2D(Reader) to obtain a matrix of double-precision values from the file.

Parameters
filethe name of the file to read.
Returns
the obtained matrix of double-precision values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readIntData() [1/4]

static int [] readIntData ( Reader  input) throws IOException
static

This is equivalent to readDoubleData(Reader), for reading integers.

Parameters
inputthe reader to obtain data from.
Returns
the obtained array of integers.
Exceptions
IOExceptionif an I/O error occurs.

◆ readIntData() [2/4]

static int [] readIntData ( URL  url) throws IOException
static

Connects to the URL referred to by the URL object url, and calls readIntData(Reader) to obtain an array of integers from the resource.

Parameters
urlthe URL object representing the resource to read.
Returns
the obtained array of integers.
Exceptions
IOExceptionif an I/O error occurs.

◆ readIntData() [3/4]

static int [] readIntData ( File  file) throws IOException
static

This is equivalent to readDoubleData(File), for reading integers.

Parameters
filethe file object represented to file to read.
Returns
the array of integers.
Exceptions
IOExceptionif an I/O error occurs.

◆ readIntData() [4/4]

static int [] readIntData ( String  file) throws IOException
static

This is equivalent to readDoubleData(String), for reading integers.

Parameters
filethe name of the file to read.
Returns
the array of integers.
Exceptions
IOExceptionif an I/O error occurs.

◆ readIntData2D() [1/4]

static int [][] readIntData2D ( Reader  input) throws IOException
static

This is equivalent to readDoubleData2D(Reader), for reading integers.

Parameters
inputthe reader to obtain data from.
Returns
the obtained 2D array of integers.
Exceptions
IOExceptionif an I/O error occurs.

◆ readIntData2D() [2/4]

static int [][] readIntData2D ( URL  url) throws IOException
static

Connects to the URL referred to by the URL object url, and calls readDoubleData(Reader) to obtain a matrix of integers from the resource.

Parameters
urlthe URL object representing the resource to read.
Returns
the obtained matrix of integers.
Exceptions
IOExceptionif an I/O error occurs.

◆ readIntData2D() [3/4]

static int [][] readIntData2D ( File  file) throws IOException
static

This is equivalent to readDoubleData2D(File), for reading integers.

Parameters
filethe file object represented to file to read.
Returns
the obtained matrix of integer values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readIntData2D() [4/4]

static int [][] readIntData2D ( String  file) throws IOException
static

This is equivalent to readDoubleData2D(String), for reading integers.

Parameters
filethe name of the file to read.
Returns
the obtained matrix of integer values.
Exceptions
IOExceptionif an I/O error occurs.

◆ readStringData() [1/4]

static String [] readStringData ( Reader  input) throws IOException
static

Reads an array of strings from the reader input.

For each line of text obtained from the given reader, this method trims leading and trailing whitespaces, and stores the remaining string. Lines starting with a pound sign (#) are considered as comments and thus skipped. The method returns an array containing all the read strings.

Parameters
inputthe reader to obtain data from.
Returns
the obtained array of strings.
Exceptions
IOExceptionif an I/O error occurs.

◆ readStringData() [2/4]

static String [] readStringData ( URL  url) throws IOException
static

Connects to the URL referred to by the URL object url, and calls readStringData(Reader) to obtain an array of integers from the resource.

Parameters
urlthe URL object representing the resource to read.
Returns
the obtained array of strings.
Exceptions
IOExceptionif an I/O error occurs.

◆ readStringData() [3/4]

static String [] readStringData ( File  file) throws IOException
static

This is equivalent to readDoubleData(File), for reading strings.

Parameters
filethe file object represented to file to read.
Returns
the array of strings.
Exceptions
IOExceptionif an I/O error occurs.

◆ readStringData() [4/4]

static String [] readStringData ( String  file) throws IOException
static

This is equivalent to readDoubleData(String), for reading strings.

Parameters
filethe name of the file to read.
Returns
the array of strings.
Exceptions
IOExceptionif an I/O error occurs.

The documentation for this class was generated from the following file: