4 Replies Latest reply: Apr 7, 2008 3:49 PM by abillconsl RSS

    How can I read Line by line a file and compared with my String?

    807591
      Hi
      I m Trying to read a file dictionnaire and try to match each line with a string to see if it the string exist on the file, if yes log the string to another file.
      below is what I get so far...
      public class test {
       
           public static void main(String[] args) throws IOException {
                
                String k = "aronas";
           
           
                   
                 FileInputStream fstream = new FileInputStream("dictionaryTest.txt");
                 DataInputStream in = new DataInputStream(fstream);
                 BufferedReader br = new BufferedReader(new InputStreamReader(in));
                 String strLine;
                    
                 while ((strLine = br.readLine()) != null)   
                     
                      System.out.println (strLine);
                     if(strLine == k)
                          System.out.println("I'm here");
                   
                     in.close();
                     
                   }
         
      }