Java 中的流和读取器有什么区别? [英] What is the difference between a stream and a reader in Java?

查看:23
本文介绍了Java 中的流和读取器有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我收到了这个问题,我认为我的回答很糟糕.我说流是一种流动的数据,而阅读器是一种我们从中读取静态数据的技术.我知道这是一个糟糕的答案,所以请以 Java 中的示例为我提供这两者之间的明确区别和定义.

Today I got this question for which I think I answered very bad. I said stream is a data that flows and reader is a technique where we read from that is a static data. I know this is an awful answer, so please provide me the crisp difference and definitions between these two with example in Java.

谢谢.

推荐答案

正如其他人所说,每个用例的用例略有不同(即使它们经常可以互换使用)

As others have said, the use cases for each are slightly different (even though they often can be used interchangeably)

由于阅读器用于阅读字符,因此当您处理具有文本性质的输入(或表示为字符的数据)时,它们会更好.我说得更好,因为 Readers(在典型用法的上下文中)本质上是具有易于读取字符输入的方法的流.

Since readers are for reading characters, they are better when you are dealing with input that is of a textual nature (or data represented as characters). I say better because Readers (in the context of typical usage) are essentially streams with methods that easily facilitate reading character input.

这篇关于Java 中的流和读取器有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆