3

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();

1 Answer 1

7

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.