我正在尝试使用以下代码将csv文件转换为arff文件:
public class Main{
public static void main(String[] args) throws Exception {
// load CSV
CSVLoader loader = new CSVLoader();
loader.setSource(new File("file.csv"));
Instances data = loader.getDataSet();//to get instance object
// save ARFF
ArffSaver saver = new ArffSaver();
saver.setInstances(data);
saver.setFile(new File("file.arff"));
saver.writeBatch();
}
}
但这不行。它会生成一个异常:“线程中的异常”主“java.lang.NoClassDefFoundError:org / bounce / net / DefaultAuthenticator”
Exception in thread "main" java.lang.NoClassDefFoundError: org/bounce/net/DefaultAuthenticator
at weka.core.WekaPackageManager.<clinit>(WekaPackageManager.java:99)
at weka.core.Utils.readProperties(Utils.java:174)
at weka.core.Capabilities.<init>(Capabilities.java:275)
at weka.core.converters.AbstractSaver.getCapabilities(AbstractSaver.java:219)
at weka.core.converters.ArffSaver.getCapabilities(ArffSaver.java:328)
at weka.core.converters.AbstractSaver.setInstances(AbstractSaver.java:162)
at Main.main(Main.java:19)
Caused by: java.lang.ClassNotFoundException: org.bounce.net.DefaultAuthenticator
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more