Example usage for org.apache.hadoop.hdfs DFSInputStream read

List of usage examples for org.apache.hadoop.hdfs DFSInputStream read

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DFSInputStream read.

Prototype

@Override
    public synchronized int read(final ByteBuffer buf) throws IOException 

Source Link

Usage

From source file:org.segrada.service.binarydata.BinaryDataServiceHadoop.java

License:Apache License

@Override
public byte[] getBinaryData(String id) throws IOException {
    if (!referenceExists(id))
        return null;

    DFSInputStream fis = client.open(rootPath + id);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    byte[] buf = new byte[1024];
    for (int readNum; (readNum = fis.read(buf)) != -1;) {
        bos.write(buf, 0, readNum);//from  w w w  . j a va 2 s.c  om
    }

    return bos.toByteArray();
}