1
1
/*
2
- * Copyright 2002-2020 the original author or authors.
2
+ * Copyright 2002-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
32
32
* its sibling {@link ResizableByteArrayOutputStream}.
33
33
*
34
34
* <p>Unlike {@link java.io.ByteArrayOutputStream}, this implementation is backed
35
- * by an {@link java.util.ArrayDeque} of {@code byte[]} instead of 1 constantly
35
+ * by a {@link java.util.ArrayDeque} of {@code byte[]} instead of 1 constantly
36
36
* resizing {@code byte[]}. It does not copy buffers when it gets expanded.
37
37
*
38
38
* <p>The initial buffer is only created when the stream is first written.
39
- * There is also no copying of the internal buffer if its contents is extracted
39
+ * There is also no copying of the internal buffer if its content is extracted
40
40
* with the {@link #writeTo(OutputStream)} method.
41
41
*
42
42
* @author Craig Andrews
@@ -177,10 +177,11 @@ public int size() {
177
177
178
178
/**
179
179
* Convert the stream's data to a byte array and return the byte array.
180
- * <p>Also replaces the internal structures with the byte array to conserve memory:
181
- * if the byte array is being made anyway, mind as well as use it. This approach
182
- * also means that if this method is called twice without any writes in between,
183
- * the second call is a no-op.
180
+ * <p>Also replaces the internal structures with the byte array to
181
+ * conserve memory: if the byte array is being created anyway, we might
182
+ * as well as use it. This approach also means that if this method is
183
+ * called twice without any writes in the interim, the second call is
184
+ * a no-op.
184
185
* <p>This method is "unsafe" as it returns the internal buffer.
185
186
* Callers should not modify the returned buffer.
186
187
* @return the current contents of this output stream, as a byte array.
@@ -197,11 +198,10 @@ public byte[] toByteArrayUnsafe() {
197
198
}
198
199
199
200
/**
200
- * Creates a newly allocated byte array.
201
- * <p>Its size is the current
202
- * size of this output stream and the valid contents of the buffer
203
- * have been copied into it.</p>
204
- * @return the current contents of this output stream, as a byte array.
201
+ * Create a newly allocated byte array.
202
+ * <p>Its size is the current size of this output stream, and it will
203
+ * contain the valid contents of the internal buffer.
204
+ * @return the current contents of this output stream, as a byte array
205
205
* @see #size()
206
206
* @see #toByteArrayUnsafe()
207
207
*/
0 commit comments