gpt4 book ai didi

java.lang.NullPointerException : Inflater has been closed On InputStreamReader 异常

转载 作者:搜寻专家 更新时间:2023-10-31 08:04:20 27 4
gpt4 key购买 nike

我有以下问题:

当我从项目加载资源时一切正常,但是当我将它放在 .jar 上并尝试加载时出现异常。

代码是:

InputStreamReader reader =
new InputStreamReader(
this.getClass().getResource(fileName).openStream())
CsvReader stream = new CsvReader(reader);
try {
while (stream.readRecord()) {
line = stream.getRawRecord();
//DO SOMETHING...
}
}catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
} finally {
stream.close();
}

stackTrace 是:

    Inflater has been closed java.lang.NullPointerException: Inflater has been closed
at java.util.zip.Inflater.ensureOpen(Inflater.java:364)
at java.util.zip.Inflater.inflate(Inflater.java:237)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:135)
at java.io.FilterInputStream.read(FilterInputStream.java:116)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at utils.csvreader.CsvReader.checkDataLength(CsvReader.java:1198)
at utils.csvreader.CsvReader.readRecord(CsvReader.java:604)

问题发生在 stream.getRawRecord() 上。我还尝试使用 BufferedReader 在 readLine();

上获得相同的结果

有什么想法吗?

最佳答案

这可能是 Java 中的错误。我有一个类似的问题,在这里描述:https://issues.apache.org/jira/browse/FELIX-1032

您的应用程序是否使用某些特殊的类加载器设置运行?

关于java.lang.NullPointerException : Inflater has been closed On InputStreamReader 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4696013/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com