doc.setBufferSize(5);
  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    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);    }  }