Results 1 to 6 of 6
Thread: Byte vs. Character Streams
- 08-06-2010, 02:25 AM #1
Byte vs. Character Streams
What is considered the most "primitive I/O"? The same article also mentions that Byte Streams are kind of a low-level I/O. This might be a silly question but I had to ask, what is the difference between low-level anything and high-level anything? Is high level more efficient? Does it have more functions? Does low-level have any advantages over high level and vice-versa?
Originally Posted by Oracle
Thanks in advance!
Source: Byte Streams (The Java™ Tutorials > Essential Classes > Basic I/O)"Experience is what you get when you don't get what you want" (Dan Stanford)
"Rise and rise again until lambs become lions" (Robin Hood)
- 08-06-2010, 02:42 AM #2
A byte is a byte. Not much lower than that.
A character can be more than one byte and so can take some logic to match up its parts to get the whole.
Depends what the stream has in it and what you want to get out.
What advantage would you get reading a character stream as bytes and then having to do some more work to get the characters. Each has its own use.
- 08-06-2010, 03:58 AM #3
Okay but both Byte Stream and Character Stream do the same thing: read() returns an int (a byte) and write() converts that int to a character.
Thus, there is no explicit difference between them."Experience is what you get when you don't get what you want" (Dan Stanford)
"Rise and rise again until lambs become lions" (Robin Hood)
- 08-06-2010, 08:24 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
InputStreams read bytes and don't care about any character encoding. Readers also may read bytes but they decode the byte values to character values. Writing goes the other way around. This basically says what you said already but the encoding/decoding stuff is the only part which makes character level IO 'higher level' than byte level IO.
kind regards,
Jos
- 08-06-2010, 03:08 PM #5
So if ones locale is US and he doesn't plan to do Internalization, it really doesn't matter what type of streams he uses. Right? It might be better to do byte streams to avoid the overhead of encoding/decoding. Right?
"Experience is what you get when you don't get what you want" (Dan Stanford)
"Rise and rise again until lambs become lions" (Robin Hood)
- 08-06-2010, 03:16 PM #6
Similar Threads
-
Streaming an image byte by byte (and similtaneosly rendering it on screen)
By ea25 in forum New To JavaReplies: 1Last Post: 04-21-2010, 02:28 AM -
Read from a certain character to a certain character
By blackstormattack in forum New To JavaReplies: 0Last Post: 03-16-2009, 11:36 AM -
reading text character by character
By bugger in forum New To JavaReplies: 2Last Post: 11-09-2007, 08:54 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks