Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 3 package jodd.io; 4 5 import jodd.util.CharUtil; 6 7 import java.io.OutputStream ; 8 import java.io.Serializable ; 9 10 14 public class StringOutputStream extends OutputStream implements Serializable { 15 16 19 protected StringBuffer buf = null; 20 21 24 public StringOutputStream() { 25 super(); 26 buf = new StringBuffer (); 27 } 28 29 35 public String toString() { 36 return buf.toString(); 37 } 38 39 42 public void close() { 43 buf = null; 44 45 } 46 47 52 public void write(byte[] b) { 53 buf.append(CharUtil.toCharArray(b)); 54 } 55 56 63 public void write(byte[] b, int off, int len) { 64 if ((off < 0) || (len < 0) || (off + len) > b.length) { 65 throw new IndexOutOfBoundsException ("Parameters out of bounds."); 66 } 67 byte[] bytes = new byte[len]; 68 for (int i = 0; i < len; i++) { 69 bytes[i] = b[off]; 70 off++; 71 } 72 buf.append(CharUtil.toCharArray(bytes)); 73 } 74 75 80 public void write(int b) { 81 buf.append((char)b); 82 } 83 } 84 85 86
| Popular Tags
|