Facebook
From Chocolate Kangaroo, 9 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 533
  1. class Importer {
  2.     public static void main(String[] args) {
  3.         new Importer().importStart();
  4.     }
  5.  
  6.     void importStart() {
  7.        
  8.         final AnnotationTranslateMappingStrategy<HagerProduct> strategy = new AnnotationTranslateMappingStrategy<>();
  9.         strategy.setTargetBean(HagerProduct.class);
  10.        
  11.         final CsvToBean<HagerProduct> csvToBean = new CsvToBean<>();
  12.  
  13.  
  14.         final Reader reader = new FileReader("1.csv")
  15.         List<HagerProduct> beanExamples = csvToBean.parse(strategy, reader);
  16.  
  17.         beanExamples.forEach { it -> println(it) }
  18.     }
  19.  
  20. }
  21.  
  22.  
  23. @CompileStatic
  24. @Canonical
  25. class HagerProduct {
  26.  
  27.     @MapToColumn(columnHeaderName = "Nr katalogowy [ symbol ]")
  28.     String nrKatalogowy
  29.  
  30. }
  31.