If you use BufferedReader.readLine (), it reads everything until the new char line. A new line character is not added to the end of the received characters. This is similar to tokenization on a new line character .. as for BufferedReader.read (), I'm not too sure why a new line is skipped. The jdk source has something like this:
public int read() throws IOException { synchronized (lock) { ensureOpen(); for (;;) { if (nextChar >= nChars) { fill(); if (nextChar >= nChars) return -1; } if (skipLF) { skipLF = false; if (cb[nextChar] == '\n') { nextChar++; continue; } } return cb[nextChar++]; } } }
Anyway for your case .. Its easy to write a program that displays a new line ...
BufferedReader br=new BufferedReader(new InputStreamReader(styleFile)); StringBuilder builder = new StringBuilder(); String line=null; while((line=br.readline())!=null){ builder.append(line).append("\n"); }
sethu source share