I need to return integer and byte array, I found that I can return them using Object[], but I'm not sure how to get integer and byte array.
It returns Object with integer and byte array:
public static Object[] readVarInt(DataInputStream in) throws IOException {
int i = 0;
int j = 0;
byte[] byteArr = null;
byte b = 0;
while (true) {
int k = in.readByte();
i |= (k & 0x7F) << j++ * 7;
if (j > 5) {
throw new RuntimeException("VarInt too big");
}
if ((k & 0x80) != 128) {
break;
}
byteArr = Arrays.copyOf(byteArr, b);
byteArr[b] = (byte) k;
b+=1;
}
return new Object[] {i, byteArr}; // <<---
}
I don't know how to get from Object[] my integer and byte array:
Object Object;
Object = Protocol.readVarInt(serv_input);
int intLength = Object[0]; // <<---
byte[] byteArray = Object[1]; // <<---
This won't work because it thinks it's array, but it's object...
(Sorry for my poor knowledge, I'm new in Java...)