Bill Manaris : Code / Read Sample Data Java
This program demonstrates how to use Scanner to read SCL and raw heart data biosignals from a file.

import java.util.Scanner;
import java.io.File;

public class ReadSampleData
{
   public static void main(String[] args) throws java.io.FileNotFoundException
   {
      // create an input scanner on the file provided as parameter to main()
      Scanner data = new Scanner(new File(args[0]));

      // read and output two lines
      System.out.println(data.nextLine());   // read first header
      System.out.println(data.nextLine());   // read second header

      // extract all SCL and raw heart data from the file
      while(data.hasNext())   // while there is more data
      {
         // there are three tokens per line (time, SCL and raw heart data)
         if(!data.hasNextDouble())   // if the next token is not a double
         {
            String timeStamp = data.next()// get time
            System.out.print(timeStamp);     // and "process" it (for now, output it)
         }
         else   // else, read SCL and raw heart data
         {
            double SCL = data.nextDouble();           // read SCL data
            double rawHeartData = data.nextDouble()// read raw heart data
            System.out.println(" " + SCL + " " + rawHeartData);
         }
      }

      data.close();      // done with the scanner
   }
}


 
(Printable View of http://www.cs.cofc.edu/~manaris/?n=Code.ReadSampleDataJava)