Saturday, May 9, 2009

Simple Program to parse a csv file

//Simple program to parse the csv file in Java
package util;
import java.io.*;

public class CsvFileAction {
public static void main(String args[]){
String fName = "//root//mycsv.csv";
String thisLine;
int count=0;
try{
FileInputStream fis = new FileInputStream(fName);
BufferedReader br=new BufferedReader(new InputStreamReader(fis));
int i=0;
while ((thisLine = br.readLine()) != null)
{
String strar[] = thisLine.split(",");
for(int j=0;j {
System.out.println(strar[j]);
}
}
} catch(Exception ex){
ex.printStackTrace();
}
}
}

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails