Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I/O question

Status
Not open for further replies.

newbee2

Technical User
Apr 21, 2002
85
I want to make a small program which reads plain text file from a disk and stores the text in StringBuffer. How do I do that?
I tryed using DataInputStream with the following:
dis.readUTF();
but it doesn't seem to work. It works only if the text file was created with the DataOutputStream and does not work with a "normal" text file...

Thanks in advance
 
Okay, rather than use a DataInputStream, you rather want to use a BufferedReader, and it's readLine() method. DataInputStream is for reading specific data types in a file such as a written String (via the DataOutputStream), not plain text.
 
Thank you - that explains it. As you can see I am still very green :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top