Updated on 2024-08-16 GMT+08:00

Writing Data to an Alluxio File

Function Description

The process of writing data to a file is as follows:

  1. Instantiate a FileSystem.
  2. Use the FileSystem instance to obtain various types of resources for writing data to files.
  3. Write the data to a specified file in Alluxio.

Sample Code

/**
* 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);
	}
}