java面试——流

Java52

流是一组具有起点和终点的有序字节。它是数据传输的总称或摘要。也就是说,两个设备之间的数据传输称为流。流的本质是数据传输。根据数据传输的特点,将流抽象为各种类别,以便于更直观的数据操作。

[En]

A stream is a set of ordered bytes with a starting point and an end point. It is the general name or abstract of data transmission. That is, the transmission of data between two devices is called a stream. The essence of the stream is data transmission. According to the data transmission characteristics, the stream is abstracted into various categories to facilitate more intuitive data operations.

1.流的创建(Stream)

这里的流是在:

import java.util.stream.Stream;可详看https://www.cnblogs.com/andywithu/p/7404101.html

使用Collection接口中的stream方法将任意集合装换为一个流。

```
public class mian {
public static void main(String[] args) throws IOException {
String contents=new String(Files.readAllBytes(Paths.get("D:\eqe.txt")), StandardCharsets.UTF_8);
List list=Arrays.asList(contents.split("\PL+"));//正则表达式按非字母分割
//普通的循环计算
int count=0;
for (String w: list) {

输入验证码查看隐藏内容

扫描二维码关注本站微信公众号 Johngo学长
或者在微信里搜索 Johngo学长
回复 svip 获取验证码
wechat Johngo学长