Created getIntArray method in Packet

This commit is contained in:
Obique PSWG
2015-10-04 10:34:23 -05:00
parent 757daba083
commit 72a30fe606
+16
View File
@@ -34,6 +34,7 @@ import utilities.Encoder;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
@@ -244,6 +245,21 @@ public class Packet {
bb.get(data);
return data;
}
public static int [] getIntArray(ByteBuffer bb) {
IntBuffer ib = bb.asIntBuffer();
int size = ib.get();
int [] ints = new int[size];
ib.get(ints);
return ints;
}
public static int [] getIntArray(ByteBuffer bb, int size) {
IntBuffer ib = bb.asIntBuffer();
int [] ints = new int[size];
ib.get(ints);
return ints;
}
/**
* Decodes the ByteBuffer stream into the passed List using the given listType instance for creating elements