Please explain the use of Java's InputStream
and OutputStream
classes. I'm confused.

- 59,888
- 27
- 145
- 179

- 2,224
- 7
- 30
- 44
-
3use google for this!! You will get tons of info! – Narendra Pathai Dec 04 '12 at 06:46
-
There are for reading and writing binary data. If you want to read/write text I suggest you use Reader/Writer classes. – Peter Lawrey Dec 04 '12 at 09:05
-
Confused about what? What part of the extensive Javadoc didn't you understand? What have you read so far? What's your question? – user207421 Dec 04 '12 at 09:08
-
@EJP:actually there is many reader and writer class and also printwriter class in java,i didn't get hte uses of these things – Thiyagu ATR Dec 04 '12 at 10:44
3 Answers
You can't get better explanation than this.
Summary:
InputStream: The abstract class; superclass of all classes representing an input stream of bytes.
OutputStream: This abstract class is the superclass of all classes representing an output stream of bytes. An output stream accepts output bytes and sends them to some sink.
Some more details are available here.
-
don't get mistaking tensed?friend....what is reader and writer class? – Thiyagu ATR Dec 04 '12 at 07:07
-
These are character streams. See this: http://stackoverflow.com/questions/3013996/byte-stream-and-character-stream – Azodious Dec 04 '12 at 07:10
The goal of InputStream and OutputStream is to abstract different ways to input and output: whether the stream is a file, a web page, or the screen shouldn't matter. All that matters is that you receive information from the stream (or send information into that stream.)
InputStream is used for many things that you read from.
OutputStream is used for many things that you write to.

- 1,821
- 4
- 17
- 35
-
so what about ByteArrayOutputStream and ByteArrayInputStreams etc? – Thiyagu ATR Dec 04 '12 at 06:52
-
@thiyagu: These two Streams are used for reading and writing the streams in the form of Bytes.. – Srinivas B Dec 04 '12 at 06:57
An I/O Stream represents an input source or an output destination. A stream can represent many different kinds of sources and destinations, including disk files, devices, other programs, and memory arrays.

- 85
- 9
-
Nice copy and paste from the [official documentation](https://docs.oracle.com/javase/tutorial/essential/io/streams.html) – Ojonugwa Jude Ochalifu Jun 05 '18 at 11:25