Discussion Locked

Calling Findstr.exe from Java program

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,
Is it possible to invoke findstr.exe of windows utility from Java program. Actually my requirement is, if some passes keyword and directory, one should be able get the all the files in that directory which contain the keyword given.
Thanks forhelp

regards
srinivas

5 replies

by jay eckles

You don't need finstr in order to accomplish this task. You need to take a look at the documentation for java.lang.String, specifically the indexOf methods might be useful. Also, I assume you already know that you'll find the java.io.File and related classes necessary.

The documentation can, of course, be found at sun's site. Here's a link to the Java 1.4 API documentation:
http://java.sun.com/j2se/1.4/docs/api/index.html
If you're using another version, you can nose around and find thedocuments that relate specifically to your version, but I don't think much has changed in the String and File classes.

by okujava

it's pretty simple to call the native progs from java:

Process p = Runtime.getRuntime().exec("findstr. exe {params}");
InputStream is = p.getInputStream();
OutputStream os = p.getOutputStream();
now u can read and write from/to streams - communicate with the tool.

cheers,

S.Okujava

This discussion is closed to new replies.