• 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 Folder and File Information

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,
This is my folder Structure in My PC... I want to retrieve the Folder Path information From D:/LIC/JeevanSurabhi/Mumbai0000290 this level.
Root Folder Array Should have RootFolder
SubFolder Array Should have Folder1,Folder2,Folder3
Files arrays should have file information of Subfolders


D:/
|-- LIC/
|-- JeevanSurabhi/
|--- Mumbai0000290
|----RootFolder
|--- Folder1 - n number of files
|--- Folder2 - n number of files
|--- Folder3 - n number of files

please give some idea

-Rodricks
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The File class has the methods you need. Create a File with the root directory for your tree, look for a list method to get the file and folders in it, and iterate the list. Are you comfortable with recursion to drill down to sub-folders? If not, this is a great place to learn it.

See how far you can get with the File class. Post some code and show us what you make! If you get stuck, we'll try to get you moving again.
 
Rodricks george
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,

I have done that today morning

static void listContents(File dir,String workingDirectory) {
String[] files; // List of names of files in the directory.
System.out.println("Directory \"" + dir.getName() + "\":");
files = dir.list();
for (int i = 0; i < files.length; i++) {

// If the file is a directory, list its contents
// recursively. Otherwise, just print its name.
File f = new File(dir, files[i]);
if (f.isDirectory())
{
int folderIndex = files[i].toString().lastIndexOf("\\");
String folderName = files[i].toString().substring(folderIndex+1,files[i].toString().length());
System.out.println("Susbstirng Foldername"+folderName);
//create folder in linux

c.unixFolderCreate(workingDirectory, folderName);
String newWorkingDirectory=workingDirectory+"/"+folderName;
listContents(f,newWorkingDirectory);
}
else
{
//Upload the file to linux
up.getLocalDataFiles("192.168.59.180", "xxxxx","xxxxx123", dir.toString(),workingDirectory );

}
}


Thanks you very much

-Rodricks
 
expectation is the root of all heartache - shakespeare. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic