• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

confusiion abut input/output stream and Reader/Writer stream

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CASE 1
InputStream and OutputStream are abstract classes that define the basic functionality for reading and writing an unstructured sequence of bytes .

case 2--
Reader nd Writer are abstract classes that define the basic functionality for reading and writing sequence of character data

querry---

what i know is that character is made up of 1 or 2 bytes now the case 1 says that it reades or writes sequence of bytes (which represent characters)

and case 2 says that it reads nad writes sequence of characters which is also same as saying like case 1......

please help
 
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why do you think bytes are the same as characters?

char != byte

Reader/Writer for characters
InputStream/OutputStream for bytes.


A character primitive size is 16 bit unsigned while a byte is 8 bit signed, but that doesn't mean a character is just two bytes.
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought Serialization wasn't included in SCJP anymore ?
 
Dieter Quickfend
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It isn't. that doesn't mean you don't have to know anything about I/O...
 
Mehdi Ben Larbi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right,i just wanted to be sure about the exam.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
InputStream and OutputStream are indeed for reading and writing bytes (binary data).

Readers and Writers are for reading and writing text. Text is ofcourse ultimately also stored as bytes on disk, but those bytes have to be interpreted a certain way to convert them into characters. How that interpretation is done is defined by the character encoding. There are many different character encodings, for example UTF-8, ISO-8859-1 etc.

A Reader reads data from an underlying InputStream and interprets the bytes using a specific character encoding to convert the bytes into chars. A Writer uses a specific character encoding to convert chars into bytes.

The number of bytes that one character takes up can be variable. For example in UTF-8 one character takes up between 1 and 4 bytes.
 
reply
    Bookmark Topic Watch Topic
  • New Topic