Advertisement
cd62131

use commons-csv

Oct 7th, 2017
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.57 KB | None | 0 0
  1. import java.nio.file.Files;
  2. import java.nio.file.Paths;
  3.  
  4. import org.apache.commons.csv.CSVFormat;
  5. import org.apache.commons.csv.CSVParser;
  6. import org.apache.commons.csv.CSVRecord;
  7.  
  8. public class Main {
  9.  
  10.   public static void main(String[] args) {
  11.     try {
  12.       for (CSVRecord line: new CSVParser(Files.newBufferedReader(Paths.get("t.csv")), CSVFormat.RFC4180)) {
  13.         int i = 0;
  14.         for (String s: line) {
  15.           System.out.printf("f%d: <%s>\n", i++, s);
  16.         }
  17.       }
  18.     } catch (Exception e) {
  19.       e.printStackTrace(System.err);
  20.     }
  21.   }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement