Help needed to read and write files!

Reply

Join Date: Oct 2008
Posts: 25
Reputation: shubhang is an unknown quantity at this point 
Solved Threads: 0
shubhang shubhang is offline Offline
Light Poster

Help needed to read and write files!

 
0
  #1
Nov 14th, 2008
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:-
  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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,358
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 252
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Help needed to read and write files!

 
0
  #2
Nov 14th, 2008
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.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 25
Reputation: shubhang is an unknown quantity at this point 
Solved Threads: 0
shubhang shubhang is offline Offline
Light Poster

Re: Help needed to read and write files!

 
0
  #3
Nov 14th, 2008
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).
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,190
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 483
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: Help needed to read and write files!

 
-1
  #4
Nov 14th, 2008
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC