使用JAVA API上传文件到FTP服务器
?private void FtpUpload() throws IOException {
??String ftpServer = "ftp server ip address";
??String username = "username";
??String password = "password";
??String filename = "filename";
??String path = "/path";
??FtpClient ftpClient = new FtpClient();
??ftpClient.openServer(ftpServer);
??ftpClient.login(username, password);
??ftpClient.binary();
??TelnetOutputStream os = ftpClient.put(filename);// 服务器上保存的文件名
??InputStream is = new FileInputStream("/path");// 本地文件路径
??byte[] bytes = new byte[1048576];
??int c;
??while ((c = is.read(bytes)) != -1) {
???os.write(bytes, 0, c);
??}
??os.close();
??ftpClient.closeServer();
?}