use of org.apache.flink.api.java.io.TextInputFormat in project flink by apache.
the class ExecutionEnvironment method readTextFile.
/**
* Creates a {@link DataSet} that represents the Strings produced by reading the given file line
* wise. The {@link java.nio.charset.Charset} with the given name will be used to read the
* files.
*
* @param filePath The path of the file, as a URI (e.g., "file:///some/local/file" or
* "hdfs://host:port/file/path").
* @param charsetName The name of the character set used to read the file.
* @return A {@link DataSet} that represents the data read from the given file as text lines.
*/
public DataSource<String> readTextFile(String filePath, String charsetName) {
Preconditions.checkNotNull(filePath, "The file path may not be null.");
TextInputFormat format = new TextInputFormat(new Path(filePath));
format.setCharsetName(charsetName);
return new DataSource<>(this, format, BasicTypeInfo.STRING_TYPE_INFO, Utils.getCallLocationName());
}
Aggregations