Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

text data files  RSS feed

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am trying to create a text data file, file extension .dat.....how do I do this??
Basically, I am supposed to write a class in java, that reads from this text file, (the text file contains inventory information such as item name, # of units, price etc), and creates objects (of some class type which I am also supposed to create). So, taht's two classes........

Can I create a wordpad file, and change the extension to .dat???

Thanks
Nazma
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can I create a wordpad file, and change the extension to .dat???


Any editor will do, as long as you save it as a text file, and give it a .dat extension. You can even save it as a .txt file, and rename it after, using for example windows explorer.
 
Marshal
Posts: 59392
187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you supposed to give it a .dat extension? If you do that, Windows will think it is a system file.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why are you supposed to give it a .dat extension?


I remember sometimes data files in old games were using that extension. They were binary files though.
 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to learn about reading and writing files in Java, then have a look at Lesson: Basic I/O in Sun's Java tutorials. Especially the page Character Streams from that tutorial shows with examples how you can read and write text files.
 
That's my roommate. He's kinda weird, but he always pays his half of the rent. And he gave me this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!