Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

whats with foo.ser? (in regarrds with serialization)

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FileOutputStream fs=new FileOutputStream("foo.ser");


is it cumpolsary to use only one extension that is .ser ?


cant we use .txt ,.docx etc
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The file system does not impose any naming constraint when creating. You would not want to use something that Windows associates with a particular program.

Personally I use .ser or something similar so I can recognize where a file came from.

Bill
 
Rob Spoor
Sheriff
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Hegde wrote:cant we use .txt ,.docx etc

Technically you can, but as William said Windows will not see that the file is not a text file or Word 2007 file. Therefore, double clicking the file will have Windows open the file with Notepad (or any other editor that is configured to open .txt files) or Word 2007. These programs can't properly display these files.

.ser is often used for files containing serialized objects, both because it makes it a bit clearer what the file contains and because .ser is not an extension used by popular applications. If you want you can use .vishal or any other thing you like. I usually use no extension at all.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Hegde wrote:FileOutputStream fs=new FileOutputStream("foo.ser");
is it cumpolsary to use only one extension that is .ser ?
cant we use .txt ,.docx etc

What happened when you tried it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic