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.


----- Original Message -----
From: "Sabari Arasu (CTC)" <[email protected]>
To: <[email protected]>
Sent: Thursday, April 17, 2003 10:11 AM
Subject: Re: Search for a file on hard drive?


> Hi,
>
> this will give the files in C:\\ drive and won't list the files in
> subfolders.
>
>
> Thanks and Regards,
> Sabari Arasu
> _______________________________
>
> TATA Consultancy Services
> #28, Ambattur Industrial Estate
> Chennai - 600 058, India
> Tel : +91 44 2625 6437
> _______________________________
>
>
> > -----Original Message-----
> > From: Mike Cronin [SMTP:[email protected]]
> > Sent: Thursday, April 17, 2003 7:01 AM
> > To:   [email protected]
> > Subject:      Re: Search for a file on hard drive?
> >
> > Should be as simple as doing the following...
> >
> >     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]);
> >       }
> >     }
> >
> > Hope that's what you're looking for.
> >
> > Mike
> >
> > -----Original Message-----
> > From: A mailing list for discussion about Sun Microsystem's Java Servlet
> > API Technology. [mailto:[email protected]] On Behalf Of Ali
> > Chadorbaf
> > Sent: Wednesday, April 16, 2003 8:35 AM
> > To: [email protected]
> > Subject: Search for a file on hard drive?
> >
> > Hi,
> > Any method available to search for a group of file(e.g : *.exe) on
> > server and
> > return the names of those files, if any?
> > Thanks.
> >
> > __________________________________________________
> > Do you Yahoo!?
> > The New Yahoo! Search - Faster. Easier. Bingo
> > http://search.yahoo.com
> >
> > ________________________________________________________________________
> > ___
> > 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
> >
> >
__________________________________________________________________________
> > _
> > 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
>
>
___________________________________________________________________________
> 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
>
>

___________________________________________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.