There is a limit I'm sure, it is pretty large I think.
What you need to do, is write exactly the same number of bytes as you read. So if you have a loop like you do. The first thing you would do is write the number of ints you are going to write, and then write just that many. You then on the read side read that first, and read just that many.
So far I've just done individual ints. I've done just four reads and four writes all to separate variables.
You have the size of your array in the first write, but having this:
for (int i = 0; i <buf.readInt(); i++)
Is that just reading the size once, or every time in the loop?
Might be safer to do:
int size = buf.readInt();
for (int i = 0; i < size; i++)