java search


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: java search

  1. #1
    Join Date
    Apr 2005
    Posts
    7

    java search

    hello,

    i have to write a java console application, which will be able to search...

    the input parameters will be:
    - search path (where to search)
    - name of the file, which will be searched

    the problem is, i dont know, how to do it...i know i have to use java.io.File,
    but it doesnt help me a lot, because i am quite new to java...

    so my question is...could someone give me an example of search...

    for example, i would like to search for file "asdf.txt" in directory C:/Temp/...

    thanks in advance...

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    For a simple directory search you cal use the list() method of the File class. E.g.
    when you instatiate an instance of File like

    File aDir=new File("c:\\tmp\\");
    String [] names=aDir.list();

    the loop through the strings returned. For each you then do a new File
    and check if that one is a directory... recursiion (uhuuu)

  3. #3
    Join Date
    Apr 2005
    Posts
    7
    i have thrown myself in reading of documentation, and got the point of the search...i am using listFiles(), because its easier to manipulate with paths...

    thanks anyway...

    i'll be back

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center