Search code examples
javacsvsupercsv

Java trying to use SuperCSV to take a string and create a pojo


I might be making this more complicated than it is but I have some code that gives me a CSV as a string. I want to turn that into a pojo for some test code I am writing. I am using SuperCSV

beanReader = new CsvBeanReader(new FileReader(csvFileName),CsvPreference.STANDARD_PREFERENCE);

Seems that the only option is to pass in a file. I would like to pass in my String. Trying to avoid getting the CSV as a string, writing it to disk, reading it back in and making a pojo


Solution

  • I believe you can use new StringReader("a,b,c\n1,2,3\n4,5,6"), give that a try.