• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Retrieve information of Folders and Files

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I want to write program which can retrieve information of Folders structures and Files.
Becaue i planted to make treeview folder and file structure.
I want folders information dynamically.
Here is my current coding, please take a look.

import java.io.IOException;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPListParseEngine;

public class FTPLocation {
public static void main(String args[]){
try{
FTPClient client=new FTPClient();

client.connect("localhost");
client.login("rootadmin","rootadmin");

FTPListParseEngine engine= client.initiateListParsing("Uploaded");
while(engine.hasNext()){
FTPFile[] filess=engine.getNext(30);
int count = filess.length;
while(count != 0){

if(filess[count-1].getRawListing().toString().startsWith("d")){
System.out.println("Folder Name:"+filess[count-1].getName());
/*******************************************************************************************/
/** HERE I WANT TO MAKE LOOPING TO GET INNER FOLDER AND FILES
/*******************************************************************************************/
}else{
System.out.println("File Name:"+filess[count-1].getName());
}
count = count - 1;
}
}
}catch(IOException e){
e.printStackTrace();
}
}
}


Here is my console output.

File Name:temp.xml
File Name:Min A Twet - Myo Kyawt Myaing.m4a
Folder Name:Old
Folder Name:New
Folder Name:InventoryEjb


Please suggest me how should i do.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should start by using code tags.
 
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic