Reading a comma delimited file (CSV) using the regex package

Use the method Pattern.split which creates an array of strings around your regular expression.

Main.java:

import java.util.regex.*;
import java.io.*;
 
public class Main
{
   public static void main(String []args) throws Exception {
      if (args.length != 1) {
         System.err.println("Usage: java Main filename.csv");
         System.exit(1);
      }
 
      Pattern p = Pattern.compile(",");
 
      BufferedReader br = new BufferedReader(new FileReader(args[0]));     
      String line = null;
      while ((line = br.readLine()) != null) {
         String[] arr = p.split(line); 
         for (int i=0; i<arr.length; i++) {
            System.out.print("t" + arr[i]);
         } 
         System.out.println();
      }
      br.close();
   }
}

Example CSV file, test.csv:

OrionServer,20.03,190.9,1000
WebLogic,190.22,234.2,93244
WebSphere,223.59,32.2,283
JBoss Server,33,44,55

Output:

	OrionServer	20.03	190.9	1000
	WebLogic	190.22	234.2	93244
	WebSphere	223.59	32.2	283
	JBoss Server	33	44	55

Alternatively, you can use the method split that was introduced in the String class since 1.4.

Main.java:

import java.io.*;
 
public class Main
{
   public static void main(String []args) throws Exception {
      if (args.length != 1) {
         System.err.println("Usage: java Main filename.csv");
         System.exit(1);
      }
 
      BufferedReader br = new BufferedReader(new FileReader(args[0]));     
      String line = null;
      while ((line = br.readLine()) != null) {
         String[] arr = line.split(","); 
         for (int i=0; i<arr.length; i++) {
            System.out.print("t" + arr[i]);
         } 
         System.out.println();
      }
      br.close();
   }
}