Apache Flink DataSet: Writing to Text File and Printing to Console
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.
原文地址: https://www.cveoy.top/t/topic/mGun 著作权归作者所有。请勿转载和采集!