Re: Search for a file on hard drive?
Ramchandra <[email protected]>
| Newsgroups | gmane.comp.java.sun.servlet |
|---|---|
| Message-ID | <[email protected]> |
Hi,
There is no perticular method for searching the files in folders and
the sub forlders of it.
Usualy all programmers start searching from a perticular folder and
then start searching into its sub folders. For doing the same
programmaticaly in Java U hv to give the following codec within a loop.
Use isFile() method of File class which returns "True" if the name specified
is a file and "False" if it is a folder.... If it is false just replace
the Folder name in File classe's constructor with the name specified and so
on..... It all depends on how do U manage the loop... The code is as
follow;
File file = new File("C:\\");
String [] files = file.list();
for (int i=0; i<files.length; i++) {
if (files[i].endsWith(".exe")) {
System.out.println(files[i]);
}
}
Cheers,
Ramachandra B.S.
Software Engineer
Conpudyne Winfosystems Ltd.(CWLGLOBAL)
Bangalore.
___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html