reading line in bufferedReader
bufferedreader, java
Solution
You can read a character at a time, and copy the data to a StringBuilder
Reader reader = ...;
StringBuilder sb = new StringBuilder();
int ch;
while((ch = reader.read()) >= 0) {
if(ch == '.') break;
sb.append((char) ch);
}
Problem
From the javadoc ``` public String readLine() throws IOException Read a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed. ``` I have following kind of text : ``` Now the earth was formless and empty. Darkness was on the surface of the deep. God's Spirit was hovering over the surface of the waters. ``` I am reading lines as: ``` while(buffer.readline() != null){ } ``` But, the problem is it is considering a line for string upto before newline.But i would like to consider line when string ends with `.`. How would i do it?