Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

about streams. names of it are confusing for me  RSS feed

 
kiran kumar reddy
Ranch Hand
Posts: 94
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know stream is a sequence of bytes.
what does FileInputStream means? the definition says
A FileInputStream obtains input bytes from a file in a file system
here what is input bytes? means does it read contents of a file and make it as a

steam? or does it make us to put bytes in to that file? if it is obtaining then why it is called FileInputStream? seems to be weird questions for all and me. help me out to clear my doubt.
 
Waldemar Macijewski
Ranch Hand
Posts: 32
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct me If I'm wrong:

A "stream" is a logical entity which either produces or consumes information. A stream can be linked to any physical device, memory, file, or a network socket - they all behave the same in Java I/O system. There are two types of streams, byte streams and character streams, they are all built upon four abstract classes: InputStream, OutputStream, Reader and Writer. In this case, FileInputStream is a InputStream which indicates that a stream from which you will be reading information is a file in a hard disk. The same applies to all subclasses of OutputStream, to what stream you will be writing information.
 
Tony Docherty
Bartender
Posts: 3268
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
means does it read contents of a file and make it as a steam?

Yes it means it reads the contents of a file as a stream of bytes.
if it is obtaining then why it is called FileInputStream

Because it is an input to your application.

Waldemar Macijewski wrote:Correct me If I'm wrong: ...

That looks like a pretty good summation to me
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!