Johnwickdev / Hightable

0 stars 0 forks source link

Class 2 #98

Open Johnwickdev opened 1 month ago

Johnwickdev commented 1 month ago

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; import org.apache.flink.streaming.api.datastream.DataStream; import org.apache.flink.core.fs.Path; import org.apache.flink.api.common.serialization.SimpleStringSchema; import org.apache.flink.streaming.connectors.fs.TextInputFormat;

public class LocalFileSourceFlink {

public static DataStream<String> createLocalFileSource(StreamExecutionEnvironment env) {
    // Define the path to the local JSON file
    String localFilePath = "path/to/local_file.json";

    // Define a TextInputFormat to read the file
    TextInputFormat textInputFormat = new TextInputFormat(new Path(localFilePath));

    return env.readFile(textInputFormat, localFilePath);
}

}