Reading a File
Function Description
Read data from a specified file in Alluxio.
Sample Code
/**
* read file
* @throws java.io.IOException
*/
private void read() throws IOException {
AlluxioURI path = new AlluxioURI(testFilePath);
FileInStream in = null;
try{
in = fSystem.openFile(path);
byte[] buffer = new byte[1024];
int len;
String content = "";
while((len = in.read(buffer)) != -1){
String bufferStr = new String(buffer,0, len);
content += bufferStr;
}
System.out.println(content);
}
catch (Exception e){
System.out.println("Failed to read file. Exception:" + e);
}
finally {
close(in);
}
} Last Article: Writing Data to a File
Next Article: Application Commissioning
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.