跳转至

从 Collection 中读取

package com.atguigu.source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;

public class CollectionDemo {
    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<Integer> source = env
                //  .fromElements(1, 2, 33); // 从元素读
                 .fromCollection(Arrays.asList(88, 99, 66));  // 从集合读

        source.print();

        env.execute();
    }
}