File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes text data files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "text data files" Watch "text data files" New topic
Author

text data files

Nazma Panjwani
Greenhorn

Joined: Jan 17, 2010
Posts: 17
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40029
    
  28
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: Aug 16, 2005
Posts: 14428
    
  23

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: text data files