Hi guys, I've made a code that will search in my text file specific strings that the user will enter in a text field. My problem is that when i enter the text and search, it will display everything and disregard the user input.

heres my code:

public void actionPerformed(ActionEvent button)
	{
		try{
		String date = textInput.getText();
		FileReader file1 = new FileReader(filename);
        BufferedReader f = new BufferedReader(file1);
        String temp = null;
        int i =0 ;
        while((temp=f.readLine()) !=null){
          i++;
          int statementFound = temp.indexOf(date);
          int statementFound1 = temp.lastIndexOf(date);
          
          if (statementFound > -1) {
//first time it finds the word
        	  searchOutput.append(temp + "\n");
            }
          if (statementFound1 == -1){
//last instance of the word not found,print
        	  searchOutput.append(temp + "\n");
          }
        }
        f.close();
   }
   catch(Exception e){}
	}

so basically if the user enters "28/2/11" ,the code will search the text file and print out in order all the lines that has that text.Not sure what im doing wrong at the moment.Anyone can help?
textInput and searchOutput are textboxes

never mind , found the solution already.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.