public static boolean downFile(String url,
int port,
String username,
String password,
String remotePath,
String fileName,
String localPath
)
{
boolean success = false;
FTPClient ftp = new FTPClient();
try
{
int reply;
ftp.connect(url, port);
ftp.login(username, password);
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
ftp.disconnect();
return success;
}
ftp.changeWorkingDirectory(remotePath);
for (FTPFile ff : fs)
{
if (ff.getName().equals(fileName))
{
File localFile = new File(localPath + "/" + ff.getName());
OutputStream is = new FileOutputStream(localFile);
ftp.retrieveFile(ff.getName(), is);
is.close();
}
}
ftp.logout();
success = true;
} catch (IOException e)
{
e.printStackTrace();
} finally
{
if (ftp.isConnected())
{
try
{
ftp.disconnect();
} catch (IOException ioe)
{
}
}
}
return success;
}
FTPFile[] fs = ftp.listFiles();//到这里的时候总是报
//org.eclipse.debug.core.DebugException:
//com.sun.jdi.ClassNotLoadedException:
//Type has not been loaded occurred while retrieving component type of array.