直接贴代码啦
/**
*
* @param zkIp
* @param zkPort
* @param tablename
* @param startRow 传null扫全表
* @param stopRow 已~结尾
* @throws Exception
*/
public static void scanTable(String zkIp,String zkPort,String tablename,String startRow,String stopRow) throws Exception {
HTablePool pool;
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum",zkIp);//
config.set("hbase.zookeeper.property.clientPort", zkPort);
pool = new HTablePool(config, 2);
HTableInterface hbTable = null;
try {
hbTable = pool.getTable(tablename); // 表名
ResultScanner rs = null;
Scan scan = new Scan();
// scan.addColumn(Bytes.toBytes("cf1"),Bytes.toBytes("qual1"));扫某一列
if (startRow != null) { // 设置扫描的范围
scan.setStartRow(Bytes.toBytes(startRow));
}
if (stopRow != null) {
scan.setStopRow(Bytes.toBytes