要创建一个DataStream,我们需要从一个Source开始,例如,一个集合或一个文件。下面是一个简单的例子说明如何从一个集合创建一个DataStream:
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<String> text = env.fromElements(
"To be, or not to be,--that is the question:--",
"Whether 'tis nobler in the mind to suffer",
"The slings and arrows of outrageous fortune"
);