Reputation: 11
I am trying to use opencsv to manipulate csv files in java
I am using BlueJ as my IDE
When I compile the code I get the following error
package au.com.bytecode.opencsv does not exist.
I also tried to compile using javac in command prompt in windows 7 but I get the same error.
I havetried surfing the web and alt of people have the same problem biy no one has given the solution to the problem.
Here is my code
import java.io.FileReader;
import java.util.Arrays;
import au.com.bytecode.opencsv.CSVReader;
public class TubeBlue1
{
@SuppressWarnings("resource")
public static void main(String[] args) throws Exception
{
//Build reader instance
//Read data.csv
//Default seperator is comma
//Default quote character is double quote
//Start reading from line number 2 (line numbers start from zero)
CSVReader reader = new CSVReader(new FileReader("data.csv"), ',' , '"' , 1);
//Read CSV line by line and use the string array as you want
String[] nextLine;
while ((nextLine = reader.readNext()) != null) {
if (nextLine != null) {
//Verifying the read data here
System.out.println(Arrays.toString(nextLine));
}
}
}
}
Please help me fix this problem.
Thanks
Vishal Ved
Upvotes: 1
Views: 2550
Reputation: 608
is the opencsv library in your classpath? that error says that the jvm compiler cannot find the class, so it is a good bet you don't have the library in the classpath for javac to find.
Upvotes: 1