Codota Logo
CsvWriter
Code IndexAdd Codota to your IDE (free)

How to use
CsvWriter
in
org.jfleet.csv

Best Java code snippets using org.jfleet.csv.CsvWriter (Showing top 8 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: jerolba/jfleet

public static <T> String writeCsvToString(CsvConfiguration<T> config, List<T> collection) throws IOException {
  CsvWriter<T> writer = new CsvWriter<>(config);
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  writer.writeAll(baos, collection);
  return baos.toString(Charset.defaultCharset().name());
}
origin: jerolba/jfleet

public void writeAll(OutputStream output, Stream<T> stream) throws IOException {
  BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output, config.getCharset()));
  if (config.isHeader()) {
    writeHeader(writer, columns);
  }
  Iterator<T> iterator = stream.iterator();
  while (iterator.hasNext()) {
    add(writer, iterator.next());
  }
  writer.flush();
}
origin: jerolba/jfleet

public void writeAll(OutputStream output, Collection<T> collection) throws IOException {
  writeAll(output, collection.stream());
}
origin: jerolba/jfleet

public CsvWriter(CsvConfiguration<T> config) {
  this.config = config;
  this.typeSerializer = config.getTypeSerializer();
  this.columns = getEntityInfo(config).getColumns();
  this.csvEscaper = new CsvEscaper(config);
  this.emptyText = Character.toString(config.getTextDelimiter()) + config.getTextDelimiter();
}
origin: jerolba/jfleet

public static void main(String[] args) throws FileNotFoundException, IOException {
  CitiBikeReader<TripAnnotated> reader = new CitiBikeReader<>("/tmp", str -> new TripAnnotatedParser(str));
  CsvConfiguration<TripAnnotated> config = new CsvConfiguration.Builder<>(TripAnnotated.class).build();
  CsvWriter<TripAnnotated> csvWriter = new CsvWriter<>(config);
  try (FileOutputStream fos = new FileOutputStream(new File("/tmp/trips.csv"))) {
    reader.forEachCsvInZip(trips -> {
      try {
        csvWriter.writeAll(fos, trips);
      } catch (IOException e) {
        e.printStackTrace();
      }
    });
  }
}
origin: jerolba/jfleet

public static void main(String[] args) throws FileNotFoundException, IOException {
  CitiBikeReader<Trip> reader = new CitiBikeReader<>("/tmp", str -> new TripParser(str));
  CsvConfiguration<Trip> csvConfiguration = new Builder<Trip>(configureEntityMapping()).build();
  CsvWriter<Trip> csvWriter = new CsvWriter<>(csvConfiguration);
  try (FileOutputStream fos = new FileOutputStream(new File("/tmp/trips.csv"))) {
    reader.forEachCsvInZip(trips -> {
      try {
        csvWriter.writeAll(fos, trips);
      } catch (IOException e) {
        e.printStackTrace();
      }
    });
  }
}
origin: jerolba/jfleet

public static void main(String[] args) throws FileNotFoundException, IOException {
  CitiBikeReader<Trip> reader = new CitiBikeReader<>("/tmp", str -> new TripParser(str));
  EntityInfoBuilder<Trip> entityInfo = new EntityInfoBuilder<>(Trip.class);
  entityInfo.addFields("bikeId", "tripduration", "starttime", "startStationId", "stoptime", "endStationId",
      "userType", "birthYear", "gender");
  CsvConfiguration<Trip> csvConfiguration = new Builder<Trip>(entityInfo.build()).build();
  CsvWriter<Trip> csvWriter = new CsvWriter<>(csvConfiguration);
  try (FileOutputStream fos = new FileOutputStream(new File("/tmp/trips.csv"))) {
    reader.forEachCsvInZip(trips -> {
      try {
        csvWriter.writeAll(fos, trips);
      } catch (IOException e) {
        e.printStackTrace();
      }
    });
  }
}
origin: jerolba/jfleet

public static void main(String[] args) throws FileNotFoundException, IOException {
  CitiBikeReader<Trip> reader = new CitiBikeReader<>("/tmp", str -> new TripParser(str));
  EntityInfoBuilder<Trip> entityInfo = new EntityInfoBuilder<>(Trip.class);
  entityInfo.addFields("bikeId", "starttime", "startStationId", "stoptime", "endStationId", "userType");
  CsvConfiguration<Trip> csvConfiguration = new Builder<>(Trip.class)
      .entityInfo(entityInfo.build())
      .alwaysDelimitText(true)
      .fieldSeparator(';')
      .lineDelimiter("\n")
      .textDelimiter('\'')
      .header(false)
      .build();
  CsvWriter<Trip> csvWriter = new CsvWriter<>(csvConfiguration);
  try (FileOutputStream fos = new FileOutputStream(new File("/tmp/trips.csv"))) {
    reader.forEachCsvInZip(trips -> {
      try {
        csvWriter.writeAll(fos, trips);
      } catch (IOException e) {
        e.printStackTrace();
      }
    });
  }
}
org.jfleet.csvCsvWriter

Most used methods

  • writeAll
  • <init>
  • add
  • getEntityInfo
  • writeHeader

Popular in Java

  • Making http requests using okhttp
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • getApplicationContext (Context)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • JButton (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now