| Author |
Differences between FileInputStream FileReader
|
O. Ziggy
Ranch Hand
Joined: Oct 02, 2005
Posts: 430
|
|
I saw these two examples in the following tutorial - http://download.oracle.com/javase/tutorial/essential/io/charstreams.html
FileReader/FileWriter
FileInputStream/FileOutputStream
One of the difference listed in the above is that both CopyBytes and CopyCharacters use an int variable to read to and write from. However, in CopyCharacters, the int variable holds a character value in its last 16 bits; in CopyBytes, the int variable holds a byte value in its last 8 bits. Can someone explain this difference please (i.e why 16bit on one and not the other. )
Thanks
|
 |
O. Ziggy
Ranch Hand
Joined: Oct 02, 2005
Posts: 430
|
|
|
Is it because java stores characters in 16bit UNICODE or is there any other specific reason?
|
 |
Mark Guo
Ranch Hand
Joined: Nov 17, 2010
Posts: 58
|
|
FileInputStream to read the image data , such as raw byte stream.
Character stream to read, consider using FileReader.
|
 |
Stephan van Hulst
Bartender
Joined: Sep 20, 2010
Posts: 3056
|
|
|
http://www.coderanch.com/t/511292/java/java/Byte-vs-Character-streams
|
 |
O. Ziggy
Ranch Hand
Joined: Oct 02, 2005
Posts: 430
|
|
|
Perfect thanks!
|
 |
 |
|
|
subject: Differences between FileInputStream FileReader
|
|
|