This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

text data files

 
Nazma Panjwani
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
 
Christophe Verré
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.
 
Campbell Ritchie
Sheriff
Posts: 48404
56
  • 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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic