“I/O系统”背景下的”抽象”。

huangapple go评论76阅读模式
英文:

"Abstraction" in the context of I/O system

问题

我正在阅读《Java入门指南,第八版》这本书,特别是第10章,关于使用I/O。我读到了这句话:“I/O流是一种在产生信息或消耗信息之间进行抽象的方式”。我了解编程背景下“抽象”的概念,但这里的“抽象”是什么意思?我不明白它是什么意思!

英文:

I was reading <b>Java A Beginner’s Guide, Eighth Edition</b> book specifically in Chapter 10, Using I/O, and I read this phrase <b>"An I/O stream is an abstraction that either produces or consumes information"</b> 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!

答案1

得分: 2

在这里,“抽象”一词是在编程上下文中使用的。Java的java.io.InputStreamjava.io.OutputStream是用于抽象底层IO技术的接口。当使用这样的流实例时,您无需关心数据的确切来源,只需使用Stream接口。实现可以是内存流磁盘上的文件、网络请求、音频流等。

当您(或您的程序)使用输入流时,只需调用read,而不必担心底层技术。对于输出流,只需调用write即可。

英文:

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.

答案2

得分: 0

例如,抽象化被用于电话上的按钮。你使用按钮来进行活动,但你不知道它是如何工作的。它只是完成任务。

在这里,它意味着你可以使用I/O流来生产或消费信息,而不用担心它是如何工作的。你只需使用它已经编写好的方法。

英文:

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.

huangapple
  • 本文由 发表于 2020年5月3日 14:32:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/61570498.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定