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!

filehandling (binary/text) with java

Status
Not open for further replies.

frag

Programmer
Dec 7, 2000
321
GB
Hi ppls!

Could someone explain me the difference between writer/reader and streams? And how do I use them?

I want to write a simple app that reads/writes an binary-file and one that reads/writes a text-file (line by line).

[sadeyes] I am stuck with this! [sadeyes]

bye

frag patrick.metz@epost.de
 
Well InputStream/OutputStream have been arround since Java 1.0. Reader/Writers came around in Java 1.1. The InputStream/OutputStream objects represent bytes, while the Reader/Writers objects represent characters.

You can combine streams with other streams to make better more complicated streams that do a very specific task. You can do the same with readers/writers.

For what you are trying to do you do not really need to use any of those. You will find it easier to work with binary or text files with a RandomAccessFile object.

With this you have a file pointer and can move forward and backwords in the file, and read/write data in a number of ways.

The best thing to start with would be the Java Docs for the JDK version your are using. If you have not downloaded them yet you may want to from:


After than good explaination of what it is in details, and how to use it can be found at the following Sun tutorial:


I hope this helps...

Rodney
 
Thank you for your help!

I already had a quick look at the Java-tutorial. Seems that it works similar to filehandling in C.

I'll check this out in detail the next week.

bye

frag patrick.metz@epost.de
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top