java - Does anyone have an example of using FtpClient.listFiles to show files in a ListView? -


i'm using apache commons ftp library , got file listing system.out.println() how can load returned filenames listview? i've searched can't find examples showing this. have example of showing ftp files in listview?

livetoggle                 .setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() {                     public void oncheckedchanged(compoundbutton buttonview,                             boolean ischecked) {                         if (ischecked) {                             directoryentries.clear();                              ftpclient client = new ftpclient();                              try {                                 client.connect(address);                                 client.login(username, password);                                  //                                 // obtain list of filenames in current                                 // working                                 // directory. when no file found empty array                                 //                                 // returned.                                 //                                 string[] names = client.listnames();                                 drawable currenticon = null;                                 (string name : names) {                                     file tmpfile = new file(name);                                     string filename = tmpfile.getname();                                     if (checkendswithinstringarray(                                             filename,                                             getresources().getstringarray(                                                     r.array.fileendingjs))) {                                         currenticon = getresources()                                                 .getdrawable(r.drawable.mimejs);                                     } else if (checkendswithinstringarray(                                             filename,                                             getresources().getstringarray(                                                     r.array.fileendinghtml))) {                                         currenticon = getresources()                                                 .getdrawable(                                                         r.drawable.mimehtml);                                     } else if (checkendswithinstringarray(                                             filename,                                             getresources().getstringarray(                                                     r.array.fileendingcss))) {                                         currenticon = getresources()                                                 .getdrawable(r.drawable.mimecss);                                     } else if (checkendswithinstringarray(                                             filename,                                             getresources().getstringarray(                                                     r.array.fileendingxml))) {                                         currenticon = getresources()                                                 .getdrawable(r.drawable.mimexml);                                     } else if (checkendswithinstringarray(                                             filename,                                             getresources().getstringarray(                                                     r.array.fileendingphp))) {                                         currenticon = getresources()                                                 .getdrawable(r.drawable.mimephp);                                     } else {                                         currenticon = getresources()                                                 .getdrawable(r.drawable.mimetxt);                                     }                                     directoryentries.add(new iconifiedtext(                                             tmpfile.getpath(), currenticon));                                     system.out.println("name = " + name);                                 }                                 ftpfile[] ftpfiles = client.listfiles();                                 (ftpfile ftpfile : ftpfiles) {                                     //                                     // check if ftpfile regular file                                     //                                     if (ftpfile.gettype() == ftpfile.file_type) {                                         system.out.println("ftpfile: "                                                 + ftpfile.getname()                                                 + "; "                                                 + fileutils                                                         .bytecounttodisplaysize(ftpfile                                                                 .getsize()));                                     }                                 }                                 client.logout();                             } catch (ioexception e) {                                 e.printstacktrace();                             } {                                 try {                                     client.disconnect();                                 } catch (ioexception e) {                                     e.printstacktrace();                                 }                             }                         }                     }                  }); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -