API for searching files with specific words

Hi ,

Can some one let me know if there is any API available for searching files which contain specific words in a particular directory?

My objective is to get the files that contain a string from a directory.In short it should work similar to the windows search which lets you search for files containing specific words

Is there any API available which lets be do this?

Message was edited by:

Bulusu

[437 byte] By [Bulusu] at [2007-11-26 8:47:30]
# 1

hello,

i have create a program that does what you want.

the program use regular expression for special search. thi is a small part of code.

protected boolean containsWord(File f)

{

Pattern patternText = null;

Matcher matcher = null;

BufferedReader br = null;

String content = null;

try

{

patternText = Pattern.compile(<yourRegularExpression>, 2);

br = new BufferedReader(new FileReader(f));

while((content = br.readLine()) != null)

{

matcher = patternText.matcher(content);

if(matcher.find())

return true;

}

}

catch(Exception e) {}

return false;

}

by gino.

for more information write to: 19gino86@fastwebnet.it

Gino86 at 2007-7-6 22:34:42 > top of Java-index,Desktop,Sun Java Desktop System...