import org.apache.flink.streaming.api.scala.{StreamExecutionEnvironment, createTypeInformation} /** * DATE:2022/10/3 13:13 * AUTHOR:GX */ object boundedStreamProcessing { def main(args: Array[String]): Unit = { val env = StreamExecutionEnvironment.getExecutionEnvironment //读取文本文件数据 val lineDataStream = env.readTextFile("H:\\javademo\\demo\\Flink1.13.0\\src\\main\\resources\\hello.text") val boundedStream = lineDataStream.flatMap(_.split(" ")) .map(x => (x, 1)) .keyBy(0) .sum(1) boundedStream.print() env.execute("boundedStreamProcessing") } }