Created
March 28, 2014 05:49
-
-
Save danhper/9826182 to your computer and use it in GitHub Desktop.
opencsv sample usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tuvistavie.foo; | |
import java.io.Reader; | |
import java.io.InputStreamReader; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import au.com.bytecode.opencsv.CSVReader; | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
new Main(); | |
} | |
public Main() throws IOException { | |
Reader r = null; | |
// r = new InputStreamReader(getClass().getResourceAsStream("/foo.csv")); | |
r = new FileReader("/home/daniel/tmp/barfoo/src/main/resources/foo.csv"); | |
CSVReader csv = new CSVReader(r); | |
for (String[] row: csv.readAll()) { | |
for (String column: row) { | |
System.out.print(column + " "); | |
} | |
System.out.println(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment