java try-with-resources语句
// 使用了try-with-resources语句来自动关闭HBaseAdmin。
public static boolean deleteColumnFamily(String tableName, String cfName) {
try (HBaseAdmin admin = (HBaseAdmin) HBaseConn.getHBaseConnection().getAdmin()) {
admin.deleteColumnFamily(TableName.valueOf(tableName), cfName.getBytes(StandardCharsets.UTF_8));
return true; // 如果删除成功,返回true
} catch (IOException ioe) {
ioe.printStackTrace(); // 或者使用日志记录器记录异常
return false; // 如果删除失败,返回false
}
}