Question: The BufferedReader.readLine() method fails to detect the carriage return on my target hardware, although it worked OK on
the emulator. Is there a work around?
Answer: This is a known defect. A solution is to write your own readLine() method that detects the newline character '\n' . For instance
public String readLine() throws java.io.IOException { StringBuffer s = new StringBuffer(); char c; c = (char) in.read(); while (c != '\n') { if ((c == '\b') && (s.length() > 0)) { s.setLength(s.length()-1); } else { s.append(c); } c = (char) in.read(); } return(s.toString()); }
(posted on the Java Discussion Group by Maurice Castro; 16-11-1999).