当前位置: 首页>>代码示例>>Java>>正文


Java CsvListWriter.writeHeader方法代码示例

本文整理汇总了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;
}
 
开发者ID:manami-project,项目名称:manami,代码行数:22,代码来源:CsvExporter.java

示例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);
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:42,代码来源:HistoDbClientImpl.java


注:本文中的org.supercsv.io.CsvListWriter.writeHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。