本文整理汇总了Java中org.supercsv.io.CsvListWriter.writeHeader方法的典型用法代码示例。如果您正苦于以下问题:Java CsvListWriter.writeHeader方法的具体用法?Java CsvListWriter.writeHeader怎么用?Java CsvListWriter.writeHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.supercsv.io.CsvListWriter
的用法示例。
在下文中一共展示了CsvListWriter.writeHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportAll
import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
@Override
public boolean exportAll(final Path file) {
try {
listWriter = new CsvListWriter(new FileWriter(file.toFile()), CsvPreference.STANDARD_PREFERENCE);
// write the header
listWriter.writeHeader(config.getHeaders());
writeAnimeList();
writeWatchList();
writeFilterList();
listWriter.close();
} catch (final IOException e) {
log.error("An error occurred while trying to export the list to CSV: ", e);
return false;
}
return true;
}
示例2: updateRecord
import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
public String updateRecord(String id, String[] headers, Object[] values) {
StringWriter sw = new StringWriter();
CsvListWriter writer = new CsvListWriter(sw, new CsvPreference.Builder('"', ',', "\r\n").build());
/*
There's no need to add the _id, as it is passed in the URL
ArrayList<String> headersList = new ArrayList<>();
headersList.add("_id");
headersList.addAll(Arrays.asList(headers));
ArrayList<Object> valuesList = new ArrayList<>();
valuesList.add(id);
valuesList.addAll(Arrays.asList(values));
writer.writeHeader(headersList.toArray(new String[] {}));
writer.write(valuesList.toArray());
*/
String idNonNull = id;
try {
writer.writeHeader(headers);
writer.write(values);
writer.close();
// if no id is provided, rely on server-side auto-increment mechanism
if (idNonNull == null) {
idNonNull = "autoIncrement";
}
try (InputStream is = httpClient.postHttpRequest(new HistoDbUrl(config,
"data/" + idNonNull + ".csv", // WARN here one must NOT use the itesla suffix (not supporting POST of new data)
Collections.emptyMap()),
sw.toString().getBytes("UTF-8"))) {
return new String(ByteStreams.toByteArray(is), StandardCharsets.UTF_8);
}
} catch (IOException e) {
throw new RuntimeException("Failed to store network values for id " + idNonNull, e);
}
}