StatBean Name: FileDataSource

Purpose: Reads data from a file on a local hard disk and saves the results in an invisible rectangular data table.

Read/Write Properties
NameTypeDescriptionPossible ValuesDefault Value
columnsNamesInFirstRowbooleanWhether the first row of the file contains names for the data columns.true,falsetrue
delimiterStringThe delimiter character."tab","space","comma","semicolon", or any single delimiter character"tab"
fileNameStringThe name of the file to be read.Any string.""
missingValueCodedoubleA numeric value used to represent missing values in the file to be read.Any numeric value.-32768.0

Other Public Methods
NameDescriptionArgumentsReturn Value
int getMaxRows()Gets the number of rows which were read.None.Number of rows.
int getMaxColumns()Gets the number of columns which were read.None.Number of columns.
boolean readData()Causes the data to be read and all listeners notified.None.true if data is read successfully
void setClipText(String Text)Supplies an actual string of data to be read. Any filename will be ignored.String of text with delimiters and carriage returns, as if read from a file.None.

Other properties are inherited from the java.awt.Object class and from the general StatDataSource class.

Code Sample

//create the FileDataSource bean
FileDataSource fileDataSource1 = new FileDataSource();

//create a bean to display the data
DataDisplayTable dataDisplayTable1 = new DataDisplayTable();

//set the filename to be read
fileDataSource1.setFileName("c:\\statbeans\\samples\\cardata.txt");

//set the delimiter character used in the file
fileDataSource1.setDelimiter("tab");

//make the data table a listener for changes in the fileDataSource bean
fileDataSource1.addDataChangeListener(dataDisplayTable1.listenerForDataChange);

//instruct the fileDataSource bean to read the file
fileDataSource1.readData();