这个问题通常是由于没有使用正确的路径或没有设置适当的权限所致。以下是一个解决方法的示例:
public static void main(String[] args) throws Exception {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream input = env.readTextFile("/path/to/input");
// define a new sink that writes to a file in a custom location
// make sure that the location exists and has proper write permissions
DataStreamSink fileStreamSink = input.addSink(new FileSink<>("file:///path/to/output", new SimpleStringEncoder<>()));
env.execute("Writing to file");
}
在这个示例中,我们使用了正确的路径并设置了合适的权限,以确保FileSink能够成功地生成输出文件夹中的日志。