更新时间:2024-08-03 GMT+08:00

写Alluxio文件

功能简介

写文件过程为:

  1. 实例化一个FileSystem。
  2. 由此FileSystem实例获取写文件的各类资源。
  3. 将待写内容写入到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);
	}
}