public void readFile() throws IOException {
// 方法体
}
public void processFile(String filePath) throws FileNotFoundException, IOException {
FileInputStream fis = new FileInputStream(filePath);
// 其他文件操作代码
}
public String readFileContent(String path) throws IOException {
return new String(Files.readAllBytes(Paths.get(path)));
}
// 适中的粒度 public void processOrder(Order order)
throws PaymentException, InventoryException, ShippingException {
// 业务逻辑
}
// 过于宽泛 public void processOrder(Order order) throws Exception {
// 不推荐
}
你可能想看: