// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;

public class ReadCSV {
   public static void main(String[] args) {
      try {
         BufferedReader r =
            new BufferedReader(new FileReader("TEST.CSV"));
         String line;
         while ((line = r.readLine()) != null) {
            System.out.println("line=" + line);
            StringTokenizer st = new StringTokenizer(line, ",|#");
            int num;
            String s;
            while (st.hasMoreTokens()) {
               s = st.nextToken();
               if (isAllDigits(s)) {
                  num = Integer.parseInt(s);
                  System.out.println("number=" + num);
               } else {
                  System.out.println("string=" + s);
               }
            }
         }
      } catch (FileNotFoundException e) {
      } catch (IOException e) {
      }
   }
   private static boolean isAllDigits(String s) {
      for (int i = 0; i < s.length(); i++) {
         if (!Character.isDigit(s.charAt(0))) {
            return false;
         }
      }
      return true;
   }
}
