File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes manipulating directories Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "manipulating directories" Watch "manipulating directories" New topic

manipulating directories

Chanpreet Julka
Ranch Hand

Joined: Nov 09, 2001
Posts: 40
I have a servlet which is supposed to go into a certain directory called year which has a subdirectory dayOfYear. The dayOfyear directory has data files which are named from the first day of the year to 365 or 366 depending on if it is a leap year. This servlet is supposed to get all the years from the year directory and get all the dayOfYears from the dayOfYear directory and print out a certain year and all of its days. How would I be able to access these directories and files, manipulate there names as strings, and output a year and all of its days as a string.
JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
You can manage directories using the package.
f = new File(path);
File[] ls = f.listFiles();
Give you the list of the directories or files you have within the specified path.
ls[i].isDirectory(), well, it's quite obvious, tell you if it is a directory or a file..
and f.getName() give you the name
Take a look at for further information

/ JeanLouis<br /><i>"software development has been, is, and will remain fundamentally hard" (Grady Booch)</i><br /> <br />Take a look at <a href="" target="_blank" rel="nofollow">Agile OpenUP</a> in the Eclipse community
Chanpreet Julka
Ranch Hand

Joined: Nov 09, 2001
Posts: 40
Ill check it out. Thanks
I agree. Here's the link:
subject: manipulating directories
jQuery in Action, 3rd edition