Re: read csv file in java
Can you post the code you are working on?
BTW This thread moved here from Member Introductions section.
Re: read csv file in java
Hi ,
This my business method code...
private void readFromVarRange(InputStream is) throws IOException{
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
System.out.println("============================== ====-------------"+br);
try
{
String strLine = "";
StringTokenizer st = null;
int lineNumber = 0, tokenNumber = 0;
//read comma separated file line by line
while( (strLine = br.readLine()) != null)
{
lineNumber++;
//break comma separated line using ","
st = new StringTokenizer(strLine, ",");
while(st.hasMoreTokens())
{
//display csv values
tokenNumber++;
System.out.println("Line # " + lineNumber + ", Token # " + tokenNumber + ", Token : "+ st.nextToken());
}
//reset token number
tokenNumber = 0;
}
}
catch(Exception e)
{
System.out.println("Exception while reading csv file: " + e);
}
From this code I am trying to get the columns data upto NA(Not Applicable) and Zero in different columns in csv file using String tokenizer in java
Please give me answer ASAP.
Re: read csv file in java
Please Edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
For testing you need to provide a small, complete program that compiles and executes.
Can you explain what the current problems are with the code? Post the program's output, explain what is wrong with it and show what you want it to be.