I have a long byte array. I need to eliminate the initial 16 bytes. Is there a shortcut do it?
Compressing a byte array is a matter of recognizing repeating patterns within a byte sequence and devising a method that can represent the same underlying information to take advantage of these discovered repetitions.
The bytearray class is a mutable sequence of integers in the range of 0 to 256.
bytes is an immutable version of bytearray – it has the same non-mutating methods and the same indexing and slicing behavior. Syntax: bytes([source[, encoding[, errors]]]) bytearray() function : Return a new array of bytes. The bytearray type is a mutable sequence of integers in the range 0 <= x < 256.
Max Size It generally depends on the JVM that we're using and the platform. Since the index of the array is int, the approximate index value can be 2^31 – 1. Based on this approximation, we can say that the array can theoretically hold 2,147,483,647 elements.
This is not the most efficient thing, but will do the trick:
// using System.Linq;
long[] array = ...;
long[] newArray = array.Skip(16).ToArray();
Check out Array.Copy
For example:
var array = //initialization
int bytesToEliminate = 16;
int newLength = array.Length - bytesToEliminate; //you may need to check if this positive
var newArray = new byte[newLength];
Array.Copy(array, bytesToEliminate, newArray, 0, newLength);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With