Mind Optimizer
Mind Optimizer

Reputation: 195

"Abstraction" in the context of I/O system

I was reading Java A Beginner’s Guide, Eighth Edition book specifically in Chapter 10, Using I/O, and I read this phrase "An I/O stream is an abstraction that either produces or consumes information" I know about abstraction in the context of programming, but what is the meaning of the word abstraction here? I did not understand what it means!

Upvotes: 2

Views: 506

Answers (2)

for example abstraction is used on a button on telephone. You use button to do activity, but you dont know how it works. It just do the job.

Here, it means you can use I/O stream for produce or consume information without wondering how it works. You just can use its already written methods.

Upvotes: 0

knittl
knittl

Reputation: 265131

The word abstraction here is used in the context of programming. Java's java.io.InputStream and java.io.OutputStream are interfaces which abstract away the underlying IO technology. When consuming such a stream instance, you do not have to care about where exactly the data comes from, you only use the Stream interface. The implementation could be an in-memory stream, a file on disk, a network request, an audio stream, etc.

When you (or your program) works with an input stream, it simply needs to call read, without worrying about the underlying technology. With output streams this becomes a simple call to write.

Upvotes: 2

Related Questions