StatBean Name: UrlDataSource

Purpose: Reads data from a file located at a specified URL 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"
missingValueCodedoubleA numeric value used to represent missind values in the file to be read.Any numeric value.-32768.0
urlStringStringThe URL of the file to be read.Any string.""

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

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

Code Sample

//create the UrlDataSource bean
UrlDataSource urlDataSource1 = new UrlDataSource();

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

//set the url filename to be read
urlDataSource1.setUrlString("http://www.statlets.com/data/commute.txt");

//set the delimiter character used in the file
urlDataSource1.setDelimiter("space");

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

//instruct the urlDataSource bean to read the file
urlDataSource1.readData();