a quicky

Associate
Joined
26 Jan 2006
Posts
1,502
ok,

a simple loop in pseudo code,

while not "new line" {
read the next character and print on screen
}


And the question,

How you tell is new line on M$ windows? '\n' doesnt work.

thanks
 
Thanks,

but how I check for '\n\r' ?

I can check one escape sequence at a time not both. Unless there is another way..?

thanks again.

ps: I blame M$ for doing the most complicated thing again!
 
Last edited:
Little weird but this is what you asked to do. I certainly wouldn't think of doing it like this. :p Not got a compiler here either to test it.

Code:
public static void main(String[] args)
        {
                String newline = System.getProperty("line.separator");
                char nextToken;
                BufferedReader in;
            try {
                in = new BufferedReader(new FileReader("foo.bar"));
                
                
                 while (!(newline.equals(nextToken = (char) in.read())))
                 {
                     System.out.println(nextToken);
                 }
                
                
            } catch (FileNotFoundException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            } catch (IOException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }


        }

Though you prolly want to use scanner and just use .hasNext() to check to see if there is any input left.
 
Back
Top Bottom