Java: what file extension should I use when writing objects with ObjectOutputStream

StackOverflow https://stackoverflow.com/questions/23602220

  •  20-07-2023
  •  | 
  •  

Question

The API shows .tmp, my text book uses .dat and I've seen .ser
Does it matter?

I'm writing an arraylist of objects

Était-ce utile?

La solution

Extensions doesn't matter. You could also use your name nicolas as extension too. Extensions are for OS to associate files to particular program.

Autres conseils

You can use any custom extensions. Extensions are meant to identify default program for the file. For example, abc.txt file should be opened with text programs. You can change extension of your video file to .txt and your computer will try to open it with text processing program. Hence, you can provide any extension unless you want to open file by particular program.

Many people use .ser. You could use .bin, anything you like really, except the ones that indicate text: .txt, .doc, etc. It's binary, not text.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top