Thread: Easy question
View Single Post
  #1 (permalink)  
Old 08-03-2007, 11:20 PM
JavaNoob JavaNoob is offline
Member
 
Join Date: Aug 2007
Posts: 10
JavaNoob is on a distinguished road
Easy question
Ok I am trying to write a program that when ran, will Println all the lines in a specific file (ss.txt). while println-ing, f textline is ever a certain name "william", it will also println "xxxxxxxx" (so that I can find that specific name when I look at the list ).

I run my program and it traverses the file and prints that lines correctly but it never does anything once it gets to the "william" name.

here is my code:

Code:
import java.io.*; public class ReadFile { public static void main(String[] args) { try { FileReader file = new FileReader("data/ss.txt"); BufferedReader buffer=new BufferedReader (file); String textline = null; while((textline = buffer.readLine()) !=null) System.out.println(textline); if (textline = "William") System.out.println("xxxxxx"); buffer.close(); } catch (IOException e) { System.out.println(e);} } }
Thanks
JN

Last edited by levent : 08-03-2007 at 11:34 PM. Reason: Code placed inside [code] tag.
Reply With Quote
Sponsored Links