更新时间:2024-06-14 GMT+08:00
写Alluxio文件
功能简介
写文件过程为:
- 实例化一个FileSystem。
- 由此FileSystem实例获取写文件的各类资源。
- 将待写内容写入到Alluxio的指定文件中。
代码样例
/**
* create file,write file
*/
private void write() throws IOException {
final String content = "hi, I am bigdata. It is successful if you can see me.";
FileOutStream out = null;
try {
AlluxioURI path = new AlluxioURI(testFilePath);
out = fSystem.createFile(path);
out.write(content.getBytes());
}
catch (Exception e){
System.out.println("Failed to write file. Exception:" + e);
}
finally {
close(out);
}
}
父主题: 开发Alluxio应用