Ria Sachdeva
Ria Sachdeva

Reputation: 113

Univocity Parser trying to parse the file, but getting error

Unable to parse the file name. The main reason is new File is expecting pathName but I am passing String. How to convert String to pathName?

        //Creating listIterator to iterate over list
        ListIterator<String> listIterator= listOfFiles.listIterator();
        while(listIterator.hasNext()) {
            fileName=listIterator.next();
            parser.beginParsing(new File(fileName));
        }
        while ((row = parser.parseNext()) != null) {
            System.out.println( Arrays.toString(row));
        }
        parser.stopParsing();
    }

Upvotes: 1

Views: 436

Answers (1)

IKo
IKo

Reputation: 5806

Here are the available constructors for the File class:

File(File parent, String child)
File(String pathname)
File(String parent, String child)
File(URI uri)

I assume that you are using this one:

 File(String pathname)

If so, the type of the parameter is String and pathname is the name of the parameter. So you just need to provide a proper path to your file. No conversion is needed.

Upvotes: 0

Related Questions