@Override public void run(String[] args) throws Exception { String tableName = args[0]; File destinationDir = new File("."); if (args.length == 2) destinationDir = new File(args[1]); DataSource dataSource = BIGS.globalProperties.getPreparedDataSource(); Table table = dataSource.getTable(tableName); ResultScanner scanner = table.getScan(table.createScanObject()); Result r = null; while ((r = scanner.next()) != null) { File destFile = new File(destinationDir, r.getRowKey()); Log.info("downloading to file " + destFile.getName()); DataItem dataItem = DataItem.fromResult(r); FileOutputStream fstream = new FileOutputStream(destFile); fstream.write(dataItem.asFileContent()); fstream.close(); } }