i´m checking a java code to implement in a project.
I found a code which looks like
my question:
What is the content after the line super.lenght = LENGHT;?
Is it bytes 21 to 21+843 (= 843 bytes?) and the content-size is now 843?
In fact i need to parse the Bytes 21+ from the original content (which includes the header too). I need to parse 843 bytes into a PacketLapData. Starting from byte index 20
The question. Do i need to consider the header still exists in the content?
Means. Is byte index 0 of content now the byte index 20 of the original contentlength of 1500?
I found a code which looks like
B4X:
public class PacketLapData extends Packet{
////////////////////////////////////////////////////////////////
// //
// LAP DATA PACKET //
// //
////////////////////////////////////////////////////////////////
// STATIC VALUES
/**
* Packet size in bytes (w/o header size).
*/
public static int LENGHT = 843;
/**
* Lap data for all cars on track (20).
*/
public ArrayList<LapData> lapData = new ArrayList<>();
/**
* Packet Lap Data constructor.
* @param content All datagram content in bytes.
*/
public PacketLapData(byte[] content){
super(Arrays.copyOfRange(content, 0, Packet.HEADER_SIZE));
super.lenght = LENGHT;
int from = Packet.HEADER_SIZE;
int to = 0;
byte[] lapcontent;
while(from < LENGHT){
to = from + LapData.SIZE;
lapcontent = Arrays.copyOfRange(content, from, to);
LapData lap = new LapData(lapcontent);
lapData.add(lap);
from += LapData.SIZE;
}
}
my question:
B4X:
content has a length of, lets say, 1500
public PacketLapData(byte[] content){
super(Arrays.copyOfRange(content, 0, Packet.HEADER_SIZE)); // HEADER_SIZE is 20
super.lenght = LENGHT;
//
Is it bytes 21 to 21+843 (= 843 bytes?) and the content-size is now 843?
In fact i need to parse the Bytes 21+ from the original content (which includes the header too). I need to parse 843 bytes into a PacketLapData. Starting from byte index 20
The question. Do i need to consider the header still exists in the content?
Means. Is byte index 0 of content now the byte index 20 of the original contentlength of 1500?
Last edited: