1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
private class FTPAsyncTask extends AsyncTask<FtpConnection, Void, String> {
private FTPClient client;
@Override
protected String doInBackground(FtpConnection... FTPc) {
this.client = new FTPClient();
try {
this.client.connect(FTPc[0].getIp(), FTPc[0].getPort());
if(FTPReply.isPositiveCompletion(this.client.getReplyCode()))
{
//Lecture d'un fichier sur FTP
return contenuFichier;
}
else
{
this.closeFTPLink();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
this.closeFTPLink();
}
return null;
}
}
protected void onPostExecute(String result) {
if(result != null && result.length() > 0)
Dp.setIp(result);
initData(true);
} |