• 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

How to get file information of any folder?

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have some files in one folder (config) like rb.properties, rb_en_us.properties, rb_fr.properties etc. My need is to count all the files (and get the file name) that are starting with rb. Please help me is there any method that look in to specified folder and do such filtering...

Thanks a lot.
[ June 08, 2005: Message edited by: rathi ji ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look into the methods on the File object. You can create a File with a directory name and list all the files in the directory. There is an optional filter you could write to use regular expressions or any other pattern matching you like to select the files you want to count. Let us know if you get stuck using those.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stan,

I did the same thing:

File dir = new File("config");
System.out.println(dir.getAbsolutePath());
String[] fileNames = dir.list();


But the issue is, When I run this code from main method it runs successfully and print absolute path perfectly but when I run it on server (It is a Web Application) it doesn't work and it print some different absolute path (probably where the server is installed)...

Please help me out anybody, what should I do?
Thanks a lot.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have problems like that deploying on both Windows and Unix. Can you put the fully qualified path & name in configuration for each environment?
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK Stan,

This is the actual path of my config folder and when I run it through main method, it prints the same path.
C:\workspace\project\config

This is the path which gets printed, when I run it as a web application:
C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\config

I am using WSAD and running application on Test Server of WSAD.

Please help me out...
Thanks.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic