943,923 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 517
  • Java RSS
Nov 14th, 2008
0

Help needed to read and write files!

Expand Post »
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:-
Java Syntax (Toggle Plain Text)
  1. PrintStream p=new PrintStream(new FileOutputStream("myfile.text"));
  2. DataInputStream in=new DataInputStream(new FileInputStream("myfile.txt"));
  3. BufferedReader br=new BufferedReader(new FileReader("myfile.text"));
  4. 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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
shubhang is offline Offline
25 posts
since Oct 2008
Nov 14th, 2008
0

Re: Help needed to read and write files!

Simple FileInputStream and FileOutputStream.

If you want to read in "binary" then there is no need to wrap those streams in anything else.
Last edited by masijade; Nov 14th, 2008 at 2:12 am.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Nov 14th, 2008
0

Re: Help needed to read and write files!

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).
Reputation Points: 10
Solved Threads: 0
Light Poster
shubhang is offline Offline
25 posts
since Oct 2008
Nov 14th, 2008
-1

Re: Help needed to read and write files!

Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Java realtime program on cellphone
Next Thread in Java Forum Timeline: coding assistance





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC