Essam wageh
Essam wageh

Reputation: 39

"import au.com.bytecode.opencsv.CSVReader" Error

I'm making a java program for converting from CSV file type to XML file type , I needed to import "open CSV" but when I write "import au.com.bytecode.opencsv.CSVReader; " It's being underlined with red , and there's error telling me that " package au.com.bytecode.opencsv.CSVReader doesn't exist " , I downloaded "open csv-3.3" and I added it to the libraries using netbeans , but nothing changed , BTW the same error is happening with "au.com.thoughtworks.xstream.XStream;" , there were some questions nearly similar to mine , but I didn't find an appropriate solution for the problem , so if anybody have a solution for the problem and the way of how to apply it to the code that will be nice ... and here are some lines" from my code ...

package fr.megiste.test;

import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.List;

import au.com.bytecode.opencsv.CSVReader;

import au.com.thoughtworks.xstream.XStream;

public class CsvToxml2 {     

    public static void main(String[] args) {

        String startFile = "start.csv";
        String outFile = "out.xml";

        try {
            CSVReader reader = new CSVReader(new FileReader(startFile));
            String[] line = null;

            String[] header = reader.readNext();

            List out = new ArrayList();

       while((line = reader.readNext())!=null){
                List<String[]> item = new ArrayList<String[]>();
                    for (int i = 0; i < header.length; i++) {
                    String[] keyVal = new String[2];
                    String string = header[i];
                    String val = line[i];
                    keyVal[0] = string;
                    keyVal[1] = val;
                    item.add(keyVal);
                }
                out.add(item);
            }

            XStream xstream = new XStream();

Upvotes: 3

Views: 8059

Answers (1)

Scott Conway
Scott Conway

Reputation: 983

From opencsv 3.1 and later the packages were refactored to com.opencsv. So CSVReader is in com.opencsv.CSVReader

Upvotes: 7

Related Questions