* <br/>
*
* @return A CoreByteBuffer with binary content.
*/
public CoreByteBuffer data() {
final CommonCore cc = this.commonCore;
return new CoreByteBuffer(this.commonCore, map(new F1<File, ByteBuffer>() {
public ByteBuffer f(File x) {
try {
final FileChannel channel = new FileInputStream(x).getChannel();
final long size = channel.size();
final ByteBuffer buffer = ByteBuffer.allocate((int) size);
int read = channel.read(buffer);
if (read != size) {
cc.report(MessageType.EXCEPTION, "Error reading data() from " + x + ". Size mismatch (" + read + " != " + size + ")");
return null;
}
channel.close();
return buffer;
} catch (FileNotFoundException e) {
cc.report(MessageType.EXCEPTION, "Error reading data() from " + x + ". File not found!");
return null;
} catch (IOException e) {
cc.report(MessageType.EXCEPTION, "Error reading data() from " + x + ". IOException!");
return null;
}
}
}).array(ByteBuffer.class));
}