ruds のメッセージ:
> Hello,
> Can someone tell me how do i find a particular string in the text file.
> Suppose i have a text file and i want to check if a word say 'computer'
> is present or not in the file ,so how do i go about it?
Read the API documentation for the java.lang.String class.
Read every line of your text.
Apply one of String metods to each line to chack word matching.
The indexOf() method will be handy.
Hi,
Use the java.io.File API to open up the file, and then use the
java.io.BufferedReader API to read it line by line. For every line,
based on case sensitivity, you can either do a
line.toUpperCase().indexOf("computer".toUpperCase()) > 1 or
line.indexOf("computer") > 1.
-cheers,
Manish
> Hello,
> Can someone tell me how do i find a particular string in the text file.
> Suppose i have a text file and i want to check if a word say 'computer'
> is present or not in the file ,so how do i go about it?
hiwa - 10 Sep 2006 07:15 GMT
Manish Pandit のメッセージ:
> Hi,
>
[quoted text clipped - 11 lines]
> > Suppose i have a text file and i want to check if a word say 'computer'
> > is present or not in the file ,so how do i go about it?
> Use the java.io.File API to open up the file
No. You can't do that. Simply create a BufferedReader passing a
FileReader(yourfile) to its constructor.
ruds - 10 Sep 2006 07:22 GMT
Manish Pandit - 11 Sep 2006 01:51 GMT
> > Use the java.io.File API to open up the file
> No. You can't do that. Simply create a BufferedReader passing a
> FileReader(yourfile) to its constructor.
Last I checked, this is how it works. Anything I missed?
-cheers,
Manish