The class presented below reads float values from a file.

Java Code:
public class ReadingFloat {
 public static float[] readFile(String file, String delimiter) 
     throws Exception {
   return(readValues(new java.io.FileInputStream(file), delimiter));
   }

 public static float[] readURL(String url, String delimiter) 
     throws Exception {
   java.net.URL addr = new java.net.URL(url);
   return(readValues(addr.openStream(), delimiter));
   }

 public static float[] readValues(java.io.InputStream in, String delimiter)
    throws  java.io.FileNotFoundException,
            java.io.IOException,
            java.lang.NumberFormatException {
   String thisLine;
   java.io.BufferedInputStream s = new java.io.BufferedInputStream(in);
   java.io.BufferedReader myInput = new java.io.BufferedReader
      (new java.io.InputStreamReader(s));
   int j = 0;
   float[] values = new float[10];

   while ((thisLine = myInput.readLine()) != null) {  
     // scan it line by line
     java.util.StringTokenizer st = 
          new java.util.StringTokenizer(thisLine, delimiter);
     while(st.hasMoreElements())
       values[j++] = Float.valueOf(st.nextToken()).floatValue();
       }
    return(values);
    }

 public static void main(String arg[]) {
   new ReadingFloat().demo();
   }
       
public void demo() {
  try {
    // we assume 10 floats (max)to be read
    float results [] = readFile("floatwithdelimitercolon.dat", ",");
    for(int i = 0; i < results.length; i++ ) {
      System.out.println(results[i]);
      }
    System.out.println();  
    results = readFile("floatwithdelimiterspace.dat", " ");
    for(int i = 0; i lt; results.length; i++ ) {
      System.out.println(results[i]);
      }
    }
  catch (Exception e) {
    e.printStackTrace();
    }
  }
}