Howdy,
I have a byte array in memory, read from a file. I would like to split the byte array at a certain point(index) without having to just create a new byte array and copy each byte at a time, increasing the in memory foot print of the operation. What I would like is something like this:
byte[] largeBytes = [1,2,3,4,5,6,7,8,9];
byte[] smallPortion;
smallPortion = split(largeBytes, 3);smallPortion would equal 1,2,3,4
largeBytes would equal 5,6,7,8,9
Thank you, Keith
EDIT: @Michael, Nice code..
I see how this example works, by just creating specific "views" of the original array.
Just a few FYI questions for others who may read this later.
How would you see this working when passing the resultant view to other classes for use? How does the reference to the original array stay in scope?
I guess since you would actually be passing references to the "views", the other classes will continue to access the view in the same manner as the example in your Main. The View contains a private reference to the original array keeping in in scope and would not be GC'ed.
I think this is the answer.
Thank you, Keith
BTW, I love this site!