Подскажите, пожалуйтса, где ошибка? Последяя строка(и) текстового файла читается неполностью:
public void readFile(String filename) {
File f=new File(filename);
StringBuilder sb = new StringBuilder();
BufferedInputStream bufferedInput = null;
int bytesRead = 0;
byte[] buffer = new byte[1024];
try {
bufferedInput = new BufferedInputStream(new FileInputStream(f));
while ((bytesRead = bufferedInput.read(buffer)) != -1) {
sb.append(new String(buffer,"windows-1251"));
}
}
catch(FileNotFoundException e) {
System.out.println("File not found" + e);
}
catch(IOException ioe) {
System.out.println("Exception while reading the file " + ioe);
}
finally {
try{
if(bufferedInput != null)
bufferedInput.close();
}
catch(IOException ioe){
System.out.println("Error while closing the stream : " + ioe);
}
}
}