Sunday, August 2, 2009

Can you give me a Java console that find a specific word in sentence each line from file?

Question Details: For example: I need to find a "Wednesday" word in each sentence by line by line.





Go ballet class next Wednesday.


On the Wednesday is going to swim class.





Then it will show the output:


Wednesday : ballet class


Wednesday : swim class





I am going to figure out in Java console to read from a file. I know already to make input/file codes.

Can you give me a Java console that find a specific word in sentence each line from file?
Take a look at the methods on the String object. In particular, consider using the indexOf(String str) method inside a conditional statement. Also keep in mind that a sentence can contain the work you are searching on multiple times so you may want to look at using the substring(int beginIndex) method to temporarily walk through the string so you can find the duplicates.


No comments:

Post a Comment