NoClassDefFoundError:com.opencsv.CSVWriter [英] NoClassDefFoundError: com.opencsv.CSVWriter
问题描述
我试图使用opencsv库来获取加密的格式数据。但是在编写CSV作者时,我得到NoClassDefFoundError。我看到很多帖子有相同的错误,也尝试了几乎所有的事情,但仍然无法纠正这个问题。以下链接有相同的错误。
I am try to use opencsv libray to get encrypted format data. But while writing on CSV writer I am getting "NoClassDefFoundError". I have seen many post related with same error and tried also almost every thing, but still not able to rectify the problem. Below link with same error.
CSVHelper code:
public String stringify(List<? extends SerializeableToCSV> objects)
throws IllegalArgumentException {
if (objects == null || objects.isEmpty())
throw new IllegalArgumentException("List of objectes passed is either null or empty");
List<String[]> strList = new ArrayList<String[]>();
// add header record
strList.add(objects.get(0).getColumnHeaders());
Iterator<? extends SerializeableToCSV> it = objects.iterator();
while (it.hasNext()) {
SerializeableToCSV element = it.next();
strList.add(element.getValueList());
}
StringWriter writer = new StringWriter();
CSVWriter csvWriter = new CSVWriter(writer, CSVHelper.VALUE_SEPERATOR, CSVWriter.NO_QUOTE_CHARACTER);
csvWriter.writeAll(strList);
try {
csvWriter.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return writer.toString();
}
All open csv library stuff in my libs folder.
Error LOG:
04-14 16:03:09.260: E/AndroidRuntime(13047): java.lang.NoClassDefFoundError: com.opencsv.CSVWriter
04-14 16:03:09.260: E/AndroidRuntime(13047): at com.stellapps.encryption.CSVHelper.stringify(CSVHelper.java:62)
04-14 16:03:09.260: E/AndroidRuntime(13047): at com.stellapps.encryption.Csv.createCSVString(Csv.java:62)
04-14 16:03:09.260: E/AndroidRuntime(13047): at com.stellapps.encryption.Csv.generateCsvEncryptedFormat(Csv.java:111)
Please let me know if any other details required. Any help will be appreciated.
One more thing I want to add is, below error before getting the above exception.
Could not find class 'com.opencsv.bean.HeaderColumnNameTranslateMappingStrategy', referenced from method com.example.encryption.CSVHelper.parse
The class for which it is giving error might be present in the class path but the jar which you require might have some dependencies.
Please find the link below to check the dependencies and add the dependent jars: http://opencsv.sourceforge.net/dependencies.html
这篇关于NoClassDefFoundError:com.opencsv.CSVWriter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!