< prev index next >
jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/ByteOutputStream.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 40,49 ****
--- 40,50 ----
*
* <ol>
* <li>doesn't do synchronization
* <li>allows access to the raw buffer
* <li>almost no parameter check
+ * </ol>
*/
public final class ByteOutputStream extends OutputStream {
/**
* The buffer where data is stored.
*/
*** 62,71 ****
--- 63,75 ----
buf = new byte[size];
}
/**
* Copies all the bytes from this input into this buffer.
+ *
+ * @param in input stream.
+ * @exception IOException in case of an I/O error.
*/
public void write(InputStream in) throws IOException {
if (in instanceof ByteArrayInputStream) {
int size = in.available();
ensureCapacity(size);
*** 82,91 ****
--- 86,96 ----
// the buffer filled up. double the buffer
ensureCapacity(count);
}
}
+ @Override
public void write(int b) {
ensureCapacity(1);
buf[count] = (byte) b;
count++;
}
*** 100,121 ****
--- 105,130 ----
System.arraycopy(buf, 0, newbuf, 0, count);
buf = newbuf;
}
}
+ @Override
public void write(byte[] b, int off, int len) {
ensureCapacity(len);
System.arraycopy(b, off, buf, count, len);
count += len;
}
+ @Override
public void write(byte[] b) {
write(b, 0, b.length);
}
/**
* Writes a string as ASCII string.
+ *
+ * @param s string to write.
*/
public void writeAsAscii(String s) {
int len = s.length();
ensureCapacity(len);
*** 136,148 ****
--- 145,160 ----
/**
* Evil buffer reallocation method.
* Don't use it unless you absolutely have to.
*
+ * @return byte array
+ *
* @deprecated
* because this is evil!
*/
+ @Deprecated
public byte toByteArray()[] {
byte[] newbuf = new byte[count];
System.arraycopy(buf, 0, newbuf, 0, count);
return newbuf;
}
*** 160,173 ****
--- 172,187 ----
* characters according to the platform's default character encoding.
*
* @return String translated from the buffer's contents.
* @since JDK1.1
*/
+ @Override
public String toString() {
return new String(buf, 0, count);
}
+ @Override
public void close() {
}
public byte[] getBytes() {
return buf;
< prev index next >