Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-01-2007, 10:34 AM
Member
 
Join Date: Oct 2007
Posts: 21
unhurt is on a distinguished road
FileReader Vs FileInputStream and same goes to output
first things first im gona say hi being the new member to the forum(don't know if this is prerequisite or not) but anyway im wondering about those 2 IO method, what are their differences and when i should use them and also their advantage and disadvantage if there is such?



Code:
//read FileReader reader = null; try { String fn1 = "Text1.txt"; FileReader reader = new FileReader(fn1); txPane.read(reader, fn1); //Vs FileInputStream fis = new FileInputStream(fn1); txPane.read( fis, null ); } catch (IOException exception) { System.err.println("Load error"); }

Last edited by unhurt : 11-01-2007 at 10:40 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-01-2007, 02:29 PM
Member
 
Join Date: Nov 2007
Posts: 4
Turtle is on a distinguished road
Hi Unhurt,

FileReader (Java Platform SE 6)

Quote:
Convenience class for reading character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are appropriate. To specify these values yourself, construct an InputStreamReader on a FileInputStream.

FileReader is meant for reading streams of characters. For reading streams of raw bytes, consider using a FileInputStream.

FileInputStream (Java Platform SE 6)

Quote:
A FileInputStream obtains input bytes from a file in a file system. What files are available depends on the host environment.

FileInputStream is meant for reading streams of raw bytes such as image data. For reading streams of characters, consider using FileReader.
I would recommend using JTextArea for using displaying editable text.

To better understand the purpose, pro's and con's of each stream: Lesson: Basic I/O (The Java™ Tutorials > Essential Classes)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-01-2007, 03:29 PM
Member
 
Join Date: Oct 2007
Posts: 21
unhurt is on a distinguished road
ah, i see, so basically filereader can only read whats on the surface? where as fileinputstream reads below that surface which can reads more than whats on the surface eh... great, thanks for sharing Turtle
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing an XML output JThangiah XML 2 03-27-2008 06:15 PM
output Camden New To Java 3 12-02-2007 12:34 AM
There's not enough memory to process the command. at java.io.FileInputStream mary New To Java 1 08-03-2007 08:17 PM
Help with filereader in java zoe Advanced Java 2 07-26-2007 11:55 AM
get the output from whoami gary Advanced Java 2 06-12-2007 03:05 PM


All times are GMT +3. The time now is 09:34 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org