如何列出所有图像文件并将其上传到FTP?

时间:2014-11-11 07:04:12

标签: java android ftp

我怎样才能轻松做到:

我在这里正确保存了所有file.directories:ArrayList fileList = new ArrayList();

如何使用此方法上传它们?

public static FTPClient con = null;

public static void upload(String path, String fileName)
{
    try
    {
        con = new FTPClient();
        con.connect("server");

        if (con.login("login", "pass"))
        {

            con.enterLocalPassiveMode(); // important!
            con.setFileType(FTP.BINARY_FILE_TYPE);

            String data = path;

            FileInputStream in = new FileInputStream(new File(data));
            boolean result = con.storeFile("/Test/" + fileName, in);
            in.close();

            con.logout();
            con.disconnect();
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}

0 个答案:

没有答案