How to make streams to read and write files (in binary) .
I have found a few Streams but do not know which one to use.
they are as follows:-

PrintStream p=new PrintStream(new FileOutputStream("myfile.text"));
DataInputStream in=new DataInputStream(new FileInputStream("myfile.txt"));
BufferedReader br=new BufferedReader(new FileReader("myfile.text"));
Printwriter pw=new PrintWriter(new FileWriter("myfile.text"));

Please tell me which ones to use to reading and writing files.
Help will be highly appreciated.

Recommended Answers

All 3 Replies

Simple FileInputStream and FileOutputStream.

If you want to read in "binary" then there is no need to wrap those streams in anything else.

So how can we input a word like "hello world" as binary,
or a number like 123?
Which stream would I use to do this(pls give the syntax).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.