} catch (BadLocationException ble) { System.out.println("Bad location exception: " + ble);
doc.fillFromLogFile(logFile); System.out.println(doc.getText(0, doc.getLength())); System.out.println("Final document"); logFile.seek(logFile.length()); logFile.writeChars("12345"); doc.appendString("12345", a); System.out.println(doc.getText(0, doc.getLength())); logFile.close(); } catch (Exception e) { System.out.println(e); e.printStackTrace();
  public static void main(String[] args) {    ConsoleStyledDocument doc = new ConsoleStyledDocument();    AttributeSet a = new javax.swing.text.SimpleAttributeSet();    // with MAX_CHARACTER = 5 this prints:    // abc, abcde, fghij, vwxyz    doc.setBufferSize(5);    try {      doc.appendString("abc", a);      System.out.println(doc.getText(0, doc.getLength()));      doc.appendString("de", a);      System.out.println(doc.getText(0, doc.getLength()));      doc.appendString("fghij", a);      System.out.println(doc.getText(0, doc.getLength()));      doc.appendString("klmnopqrstuvwxyz", a);      System.out.println(doc.getText(0, doc.getLength()));    } catch (BadLocationException ble) {      System.out.println("Bad location exception: " + ble);    }  }