下面是我写给FTP的一段代码到服务器的HTML文件。虽然我在代码中没有错误,但是当我执行程序时,我在FTPClient上得到No Class Def Found Error。我已经下载了commons-net-3.6-bin并将以下jar文件导入到我的项目库中 公共净3.6.jar 公共净3.6 source.jar 公地净例子-3.6.jar
不知道从哪里开始。
String projectPath = System.getProperty("user.dir");
String ImportSKU = projectPath + "Import SKU.HTML";
File file = new File(ImportSKU);
FTPClient client = new FTPClient();
String filename = ImportSKU;
// Read the file from resources folder.
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try (InputStream is = classLoader.getResourceAsStream(filename)) {
client.connect("ftp://www.data.com");
client.login("usedid", "password");
// Store file to server
client.storeFile(filename, is);
client.logout();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}