aspose file tools*
The moose likes Beginning Java and the fly likes repeated println Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "repeated println" Watch "repeated println" New topic
Author

repeated println

Crescento Anho
Greenhorn

Joined: Nov 20, 2007
Posts: 4
I want to check which words that i read from an input text file (one word per line) do not exist in an array of strings (that I already have in my program). I used the .equals to compare the word to every word of my array. Then when I ask the program to print, when a word does not occur in the array I see e.g. 10 times (=number of elements in the array) the phrase ("The word" + fileLine+ "does not occur."). What should I do? When using array there is no 'boolean cointains ();'
[ November 22, 2007: Message edited by: Crescento Anho ]
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1344
    
  12
I guess you could write a method which returns a boolean...
The first thing that comes to mind would be

// create method that takes two parameters: the fileLine, and the array
// set a boolean flag to false
// go through the whole array
// if you encounter the word, set the flag to true
// return the flag

There are probably dozens of good ways to do it (and maybe even something in the API).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: repeated println
 
Similar Threads
why does this code work
MidiUnavailableException and JMF
BufferedReader into a String array
How to convert Char array to two dimensional string
can we typecast String to String array