package msoe.se1011.bioanalyzer; /* * Created on Apr 27, 2005 * * Example.java * @author: hornick */ import java.util.Scanner; import javax.swing.*; /** * This class contains sample code that illustrates how to use * the FileReader class to read values from a file. * @author hornick */ public class Example { /** * The main method that contains the example code * @param args */ public static void main(String[] args) { String filename = "data.txt"; // the disk file to read from //The FileReader class only has static methods and attributes, // so there is no need to create an instance of it. In fact, // we can't create an instance of FileReader, as the constructor is private. String data = FileReader.readFileIntoString(filename); // try reading the file into a String int status = FileReader.getStatus(); // get the status of the previous call if( status != FileReader.DATA_READ_OK ) { // file not opened JOptionPane.showMessageDialog(null, "The FileReader encountered an error.\n " + "The file could not be opened; status = " + status ); System.exit(0); // quit } else { // file was opened successfully by the PulseReader constructor; now read data System.out.println("The string read is: " + data); System.out.println("The number of values in the string is: " + FileReader.getNumberOfValuesRead() ); //TODO: Create a Scanner that reads each value out of the monster string, // and puts each value into an array of int's. // Then plot the values in a chart. } } // end main() } // end class Example