Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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();
like image 846
Essam wageh Avatar asked Sep 27 '26 04:09

Essam wageh


1 Answers

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

like image 61
Scott Conway Avatar answered Sep 28 '26 18:09

Scott Conway



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!