平常最经常看到的就是IOstream了,还有其他各种stream,FileStream,NetworkStream。

stream表示的是一连串的objects,(在java的世界里,所有的东西都是objects),譬如连续好几个int,好几个float,或者其他类对象等等。

想象stream就是一条河流,我们不用关心它的源头在哪里,只需要知道我们可以在目的地(海?)可以收集到来自五湖四海的一样。一般情况下,我们也不用管这河流源头在哪里,只需要拿到我们需要的东西。

同样,通过stream,我们想获取data,不用管其源头( a file, a socket,serial ports等等)。

stream就是提供了我们一个抽象层把我们和data的来源隔开。

Typical operations on a stream:

  • read one byte. Next time you read, you'll get the next byte, and so on.
  • read several bytes from the stream into an array
  • seek (move your current position in the stream, so that next time you read you get bytes from the new position)
  • write one byte
  • write several bytes from an array into the stream
  • skip bytes from the stream (this is like read, but you ignore the data. Or if you prefer it's like seek but can only go forwards.)
  • push back bytes into an input stream (this is like "undo" for read - you shove a few bytes back up the stream, so that next time you read that's what you'll see. It's occasionally useful for parsers, as is:
  • peek (look at bytes without reading them, so that they're still there in the stream to be read later)

summary:

a stream is just a source of input, hiding away (abstracting) another source. As long as you don't break the abstraction, your code will be very flexible.

注:本文从stackoverflow总结而来,详细请看:

http://stackoverflow.com/questions/1216380/what-is-a-stream/1216400#1216400

http://stackoverflow.com/questions/507747/can-you-explain-the-concept-of-streams

什么是stream?相关推荐

  1. stream流对象的理解及使用

    我的理解:用stream流式处理数据,将数据用一个一个方法去 . (点,即调用) 得到新的数据结果,可以一步达成. 有多种方式生成 Stream Source: 从 Collection 和数组 Co ...

  2. Cuda Stream流 分析

    Cuda Stream流分析 Stream 一般来说,cuda c并行性表现在下面两个层面上: • Kernel level • Grid level Stream和event简介 Cuda stre ...

  3. CUDA 7 Stream流简化并发性

    CUDA 7 Stream流简化并发性 异构计算是指高效地使用系统中的所有处理器,包括 CPU 和 GPU .为此,应用程序必须在多个处理器上并发执行函数. CUDA 应用程序通过在 streams ...

  4. 关于Adodb.Stream的使用说明

    组件:"Adodb.Stream" 有下列方法: Cancel 方法      使用方法如下      Object.Cancel      说明:取消执行挂起的异步 Execut ...

  5. stream map方法_Java Stream中map和flatMap方法

    最近看到一篇讲stream语法的文章,学习Java中map()和flatMap()方法之间的区别. 虽然看起来这两种方法都做同样的事情,都是做的映射操作,但实际上差之毫厘谬以千里. 通过演示Demo中 ...

  6. stream流map 多个字段_stream流根据对象指定字段去重

    先封装一个去重的方法 import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.fun ...

  7. Java8 Stream应用:Map合并、过滤、遍历、values int求和等

    1. Java多个Map合并 // 多个Map<Long,Integer>, 根据key相同的,value累积求和: public static Map mapCombine(List&l ...

  8. stream filter 用法_JDK1.8新特性Stream和Collectors19个常用示例总结

    关于Stream和Collectors的用法,这应该是总结的最全的文章了,大家可以收藏一下. 一:简介 java.util.Stream 表示能应用在一组元素上一次执行的操作序列.Stream 操作分 ...

  9. RTMP协议中的Chunk Stream ID (CID)的作用

    一.协议分层 RTMP包是以Message的结构封装的,结构如下所示: 1)Message Type ID在1-7的消息用于协议控制,这些消息一般是RTMP协议自身管理要使用的消息,用户一般情况下无需 ...

  10. java父子表_数据库二维表转父子关系,java,stream,list

    需求描述:把数据库中的省市二维表,查询到内存中后,转换为父子层级关系.通过jdk8中的stream方式实现. 数据关系: 320004    福建省    320507    南平市 430000   ...

最新文章

  1. Kafka文件存储机制那些事
  2. 【opencv系列03】OpenCV4.X视频捕获与显示
  3. 通过避免下列 10 个常见 ASP.NET 缺陷使网站平稳运行
  4. 【恋上数据结构】布隆过滤器(Bloom Filter)原理及实现
  5. CommonJS模块的循环加载
  6. Windows10设置动态视频桌面(占少量内存)
  7. Python 国产库推荐:musicpy
  8. 全国计算机二级考试vb考点,计算机二级考试VB考点:通用对话框控件
  9. FileZilla Server + FlashFXP 快速搭建FTP服务
  10. 晓庄师范的3 4 计算机应用,2021全国应用心理学专业大学排名(5篇)
  11. 迅速崛起 盘点2018年中国AI芯片“四小龙”
  12. 移动节点的间接路由方式
  13. 一锄落花,葬在了寂寞的天涯
  14. Java、显示每月第一天是星期几
  15. SumatraPDF一个很nice的PDF开源项目
  16. 解决高德地图api叠加Imagelayer播放雷达图闪烁
  17. 调用摄像头接口方法合集
  18. 对于rh v5系列服务器,华为rh2288v5服务器重定向问题引起pxe报错
  19. iPhone4/4s 5.1.1版本越狱后无法连接iTunes,出现0xE8000012错误的解决方法
  20. 创维电视显示连接服务器失败怎么回事,创维电视显示已连接路由器,却无法联网-创维电视连接路由器显示连接失败...

热门文章

  1. continue、break和return的区别
  2. (一)Dart基本语法
  3. 记一次在朋友圈里卖家乡特产枇杷的经历
  4. 2005-陶陶摘苹果
  5. 李开复:算法的力量 (完整版)
  6. ehcache磁盘缓存说明
  7. C#万能工具类部分代码
  8. 培训python机构排名
  9. win10下怎样设置的输入栏M图标和中英文输入提示
  10. Android中文API:AbsListView