-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathDataBuffer.java
More file actions
28 lines (21 loc) · 703 Bytes
/
DataBuffer.java
File metadata and controls
28 lines (21 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.badlogic.gdx.utils;
import com.badlogic.gdx.utils.StreamUtils.OptimizedByteArrayOutputStream;
/** Extends {@link DataOutput} that writes bytes to a byte array.
* @author Nathan Sweet */
public class DataBuffer extends DataOutput {
private final OptimizedByteArrayOutputStream outStream;
public DataBuffer () {
this(32);
}
public DataBuffer (int initialSize) {
super(new OptimizedByteArrayOutputStream(initialSize));
outStream = (OptimizedByteArrayOutputStream)out;
}
/** Returns the backing array, which has 0 to {@link #size()} items. */
public byte[] getBuffer () {
return outStream.getBuffer();
}
public byte[] toArray () {
return outStream.toByteArray();
}
}