Skip to content

Instantly share code, notes, and snippets.

@mattkatz
Created August 31, 2010 15:30
Show Gist options
  • Save mattkatz/559200 to your computer and use it in GitHub Desktop.
Save mattkatz/559200 to your computer and use it in GitHub Desktop.
//merging http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html
//and http://vafer.org/blog/20071112204524
ftpClient = getConnectedFTPClient();
public class GalleryLister{
public FTPClient mFtp;
public ArrayList mAccumulator;
private String sep = "|";
private String prefix = "";
public GalleryLister(FTPClient ftp, ArrayList accumulator){
mFtp = ftp;
mAccumulator = accumulator;
}
public final void traverse(FTPFile f) {
if(f.isDirectory()){
prefix.concat(sep);
onDirectory(f);
//change to the directory
mFtp.changeWorkingDirectory(f.getName());
final FTPFile[] children = mFtp.listFiles();
for(FTPFile child : children){
traverse(child);
}
//return to parent directory
mFtp.changeToParentDirectory();
prefix = prefix.substring(1);
}
}
public void onDirectory(final FTPFile d){
}
public void onFile(final FTPFile f){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment