我正在读一本书 Snappy Compressed file
从本地到 java
.
File snappyFile = new File(fileName);
Configuration conf = new Configuration();
CompressionCodec codec = (CompressionCodec)
ReflectionUtils.newInstance(SnappyCodec.class, conf);
FileInputStream is2 = new FileInputStream(snappyFile);
CompressionInputStream cis = codec.createInputStream(is2);
BufferedReader cr = new BufferedReader(new InputStreamReader(cis));
我的代码在reflectionutils.newinstance处出现异常
Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodException: org.xerial.snappy.SnappyCodec.<init>()
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:128)
at org.finra.oats.AWS.AWSnappyRead.run(AWSnappyRead.java:64)
at org.finra.oats.AWS.AWSnappyRead.main(AWSnappyRead.java:48)
Caused by: java.lang.NoSuchMethodException: org.xerial.snappy.SnappyCodec.<init>()
at java.lang.Class.getConstructor0(Class.java:2849)
at java.lang.Class.getDeclaredConstructor(Class.java:2053)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:122)
... 2 more
是因为版本不匹配的问题。我正在使用 snappy 1.1.1.2
版本
1条答案
按热度按时间yqkkidmi1#
要读写snappy压缩文件,可以使用提供的snappyinputstream/snappyoutputstream类。