home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- public class ByteArrayOutputStream extends OutputStream {
- protected byte[] buf;
- protected int count;
-
- public ByteArrayOutputStream() {
- this(32);
- }
-
- public ByteArrayOutputStream(int var1) {
- this.buf = new byte[var1];
- }
-
- public synchronized void write(int var1) {
- int var2 = this.count + 1;
- if (var2 > this.buf.length) {
- byte[] var3 = new byte[Math.max(this.buf.length << 1, var2)];
- System.arraycopy(this.buf, 0, var3, 0, this.count);
- this.buf = var3;
- }
-
- this.buf[this.count] = (byte)var1;
- this.count = var2;
- }
-
- public synchronized void write(byte[] var1, int var2, int var3) {
- int var4 = this.count + var3;
- if (var4 > this.buf.length) {
- byte[] var5 = new byte[Math.max(this.buf.length << 1, var4)];
- System.arraycopy(this.buf, 0, var5, 0, this.count);
- this.buf = var5;
- }
-
- System.arraycopy(var1, var2, this.buf, this.count, var3);
- this.count = var4;
- }
-
- public synchronized void writeTo(OutputStream var1) throws IOException {
- var1.write(this.buf, 0, this.count);
- }
-
- public synchronized void reset() {
- this.count = 0;
- }
-
- public synchronized byte[] toByteArray() {
- byte[] var1 = new byte[this.count];
- System.arraycopy(this.buf, 0, var1, 0, this.count);
- return var1;
- }
-
- public int size() {
- return this.count;
- }
-
- public String toString() {
- return new String(this.buf, 0, this.count);
- }
-
- public String toString(String var1) throws UnsupportedEncodingException {
- return new String(this.buf, 0, this.count, var1);
- }
-
- /** @deprecated */
- public String toString(int var1) {
- return new String(this.buf, var1, 0, this.count);
- }
- }
-