Univocity Parsers,"无法解析方法writeValue(int)"?

时间:2016-01-13 12:43:17

标签: parsing csv writing

Univocity Parsers,"无法解析方法writeValue(int)"出现以下代码,在IntelliJ中打开,任何帮助将不胜感激:

public void write(){

        // Writing to an in-memory byte array. This will be printed out to the standard output so you can easily see the result.
        ByteArrayOutputStream csvResult = new ByteArrayOutputStream();

        // CsvWriter (and all other file writers) work with an instance of java.io.Writer
        Writer outputWriter = new OutputStreamWriter(csvResult);

        TsvWriter writer = new TsvWriter(outputWriter, new TsvWriterSettings());

        writer.writeHeaders("A", "B", "C", "D", "E");

        //writes a value to the first column
        writer.writeValue(10);

        //writes a value to the second column
        writer.writeValue(20);

        //writes a value to the fourth column (index 3 represents the 4th column - the one with header "D")
        writer.writeValue(3, 40);

        //overrides the value in the first column. "A" indicates the header name.
        writer.writeValue("A", 100.0);

        //flushes all values to the output, creating a row.
        writer.writeValuesToRow();
    }

1 个答案:

答案 0 :(得分:1)

您似乎从使用2.0.0-SNAPSHOT版本构建的示例中获取了此示例。更新您的pom.xml以使用

<dependency>
    <groupId>com.univocity</groupId>
    <artifactId>univocity-parsers</artifactId>
    <version>2.0.0-SNAPSHOT</version>
</dependency>

您可能还需要将以下内容添加到pom.xml以使maven能够获取快照构建:

<repositories>
    <repository>
        <id>ossrh</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>

如果您不使用maven,可以直接转到以下网址:https://oss.sonatype.org/content/repositories/snapshots/com/univocity/univocity-parsers/2.0.0-SNAPSHOT/

最后,此示例取自快照版本,您之后的方法已重命名为addValue。查看示例here