-
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...
-
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)
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks