• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

I/O and streams

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic