我试图从ftp下载csv文件。 文件已成功下载,但它在该文件中提供了垃圾值。 以下是我的代码
String server = "client.in";
int port = 21;
String user = "user";
String pass = "pwd";
InputStream input=null;
BufferedWriter out = null;
FTPClient ftpClient = new FTPClient();
try {
ftpClient.connect(server, port);
ftpClient.login(user, pass);
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
FileOutputStream fos = null;
String filename = "Test.csv";
OutputStream data = (OutputStream) new FileOutputStream("Test/"+filename);
ftpClient.retrieveFile(filename, data);
data.close();
}
catch(Exception e)
{
e.printStackTrace();
}
解决方案是什么...... 请帮忙