Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I/O and streams  RSS feed

 
sandip karmarkar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
Pl. read the following code
FileOutputStream out_new = new FileOutputStream("Sandip");
out_new.write(5);
out_new.close();
I want to know what will be the type of file ( whether .txt or .dat or something else ) if I do not mention file extention along with the file name?
When I executed this code on my machine, Winamp Media file was created. Can some one explain this ?
Regards
Sandip Karmarkar
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandip,
The output file will just be called "Sandip". There is no extension, so Windows should not associate it with anything. On my machine, I get a dialog box asking me what program I want to open this file with. I think your machine has Windows Media Player associated to any file without an extension. If you want to test this out, go to any editor and create a dummy file without an extension and see what Windows uses to open this file.
Java doesn't know how to associate file type to an application. If you use "Sandip.txt", Windows will think it's a text file. If you use "Sandip.dat", Windows will think it's a Media file.
-Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!