Skip to content

How to create own filetype?

I want to create own filetype to save objects in my app. Basically, I urgently do not need new filetype, but it will be better.

I have class. For example Car. It has constructor (String name, String color, int length, Driver driver). When a car is created (its instance), how to save it like a file?

Answer

To save object to file you need serialization.

You can choose whatever file extension we like e.g. .car.

Good serialization tutorial.