Writing Data to a File
Function Description
The process of writing data to a file is as follows:
- Instantiate a FileSystem.
- Use the FileSystem instance to obtain various types of resources for writing data to files.
- 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);
}
} Last Article: Initializing Alluxio
Next Article: Reading a File
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.