/* Punters Lounge JAVA programming course * * Lesson61.java * * Author : Erik Datapunter * Date : 28/apr/2004 * * Text manipulation example program * */ public class Lesson61 { public static void main(String[ ] arguments) { // string buffers to hold the existing text StringBuffer mytext = new StringBuffer(100); // one string to hols the word to look for String searchword = arguments[0]; int position = 0; // use the append method to put the text into the buffer mytext = mytext.append(arguments[1]); // use the indexOf method to find out if the search word is in the text position = mytext.indexOf(searchword); // if position is -1 then the word is not in the text,.. if (position == -1) { System.out.println("Not found."); } // ...else its in the text starting at that position else { System.out.println("Found."); } } }