I\'ve written the following code:
public class WriteToCharBuffer {
public static void main(String[] args) {
String text = \"This is the data to write in
This is because of readLine(). From Java Docs:
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.
So what is happening is your "\n" are being considered as a line feed so reader considers that to be a line.