Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic