1 19 20 package org.netbeans.modules.tasklist.core.util; 21 22 import java.io.*; 23 24 30 public final class IndentedWriter extends PrintWriter { 31 private boolean needIndent = true; 32 private String indent = ""; 33 34 41 public IndentedWriter(Writer out, boolean autoFlush) { 42 super(out, autoFlush); 43 } 44 45 50 public IndentedWriter(Writer out) { 51 super(out); 52 } 53 54 66 public IndentedWriter(OutputStream out, boolean autoFlush) { 67 super(out, autoFlush); 68 } 69 70 80 public IndentedWriter(OutputStream out) { 81 super(out); 82 } 83 84 public void println() { 85 super.println(); 86 needIndent = true; 87 } 88 89 public void write(String s) { 90 if(needIndent) { 91 super.write(indent); 92 needIndent = false; 93 } 94 super.write(s); 95 } 96 97 100 public void indent() { 101 indent += " "; 102 } 103 104 107 public void unindent() { 108 indent = indent.substring(4); 109 } 110 } 111 | Popular Tags |