Serialize and deserialize n dimensional int array
1. writing an int to an OutputStream instance  

Instead of splitting your int to bytes and putting them in a byte array, directly consume your bytes like this:

out.write((n &gt;&gt;&gt; 24) &amp; 0xFF);
out.write((n &gt;&gt;&gt; 16) &amp; 0xFF);
out.write((n &gt;&gt;&gt;  8) &amp; 0xFF);
out.write((n &gt;&gt;&gt;  0) &amp; 0xFF);


This is taken from the source code of FileOutputStream, which offers methods to write primitives to a stream.

This offers higher performance compared to packing your int in a byte array. Internally, the OutputStream.write(byte[] b) method is iterating over your byte array and calling out.write(int b) anyways. The same goes for the reading part as well I guess.

2. public helper methods  

I would make readInt and writeInt private/protected. There is no need to expose them. If you plan to call them from other classes, a class called "IntArraySerializer" doesn't seem to be the correct place for them. Instead you should put them in a new class with a more expressive name like "StreamUtilities".

3. argument checking  

You might want to check each argument of your public methods for null and throw an IllegalArgumentException if it is null, specifying which argument is null. This makes future debugging easier: You or other programmers won't have to look at the source code in order to debug a NullPointerException...  

Throw and IllegalArgumentException in writeIntArr if the object is not an array.