The correct method name is 'writeAsText()' instead of 'toDataStream()' in Apache Flink's 'DataSet' API. This method writes the 'DataSet' to a text file or a text stream.

Example usage:

DataSet<String> input = env.fromElements('hello', 'world');
input.writeAsText('output.txt');

This will write the contents of the 'DataSet' to a text file named 'output.txt'.

Alternatively, you can also use 'print()' method to print the contents of the 'DataSet' to the console:

DataSet<String> input = env.fromElements('hello', 'world');
input.print();

This will print the contents of the 'DataSet' to the console.

Apache Flink DataSet: Writing to Text File and Printing to Console

原文地址: https://www.cveoy.top/t/topic/mGun 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录