Firstly, do you really need to be using non-generic collections? It's almost always better to use List<T>
than ArrayList
unless you're actually targeting .NET 1.1, which seems unlikely.
The equivalent of using ObjectOutputStream
in Java is to use BinaryFormatter
in .NET. You can use GZipStream
for compression. Note that these are classes, not namespaces - it's worth clearing up the terminology in your mind. FileOutputStream
and FileInputStream
are both represented by FileStream
in .NET.
It's also worth being aware that using the native binary serialization in either .NET or Java is somewhat fragile in terms of versioning. You may want to consider using alternatives such as JSON, Protocol Buffers, Thrift, XML etc.
Personally I would recommend that you learn C# and .NET from scratch, rather than trying to port Java code without really knowing the idioms of the language and platform you're porting to. For example, you definitely want to use using
statements rather than using "manual" finally
blocks to dispose of resources.