1 23 24 29 30 package com.sun.enterprise.admin.mbeans.jvm; 31 import java.io.*; 32 33 35 class StringBuilderNewLineAppender { 36 37 private StringBuilder sb; 38 private static final String sep = System.getProperty("line.separator"); 39 40 StringBuilderNewLineAppender(final StringBuilder sb) { 41 this.sb = sb; 42 } 43 StringBuilderNewLineAppender append(final String s) { 44 sb.append(s); 45 sb.append(sep); 46 return ( this ); 47 } 48 public String toString() { 49 return ( sb.toString() ); 50 } 51 public String toString(String ... filterOut) { 52 String sbString = sb.toString(); 53 BufferedReader in = new BufferedReader(new StringReader(sbString)); 54 sb = new StringBuilder (); 55 56 try 57 { 58 readloop: 59 for(String s = in.readLine(); s != null; s = in.readLine()){ 60 for(String filter : filterOut){ 61 if(s.startsWith(filter)) 62 continue readloop; } 64 append(s); 65 } 66 } 67 catch(Exception e) 68 { 69 return sbString; 71 } 72 73 return toString(); 74 } 75 76 } 77 | Popular Tags |