https://meilishiyan-song.taobao.com/

try块中如果明明应该获取到了值,却报错 因为定义了局部变量

说明:如果sheet 定义在try中,就会报错,即使方法能返回sheet ,因为定义在了try中也会报错。

所以开发中,try中能不定义就不定义

XSSFSheet sheet = null;
try {
log.debug(UtilDateTime.getTimestamp(System.currentTimeMillis()) + ".readExcel.start...constantsvariable={}",
constantsvariable.getSheet());
sheet = constantsvariable.getSheet();
} catch (Exception e) {
log.error(UtilDateTime.getTimestamp(System.currentTimeMillis()) + ".readExcel.exception....异常...异常信息:{}",
e);
throw new Exception(
UtilDateTime.getTimestamp(System.currentTimeMillis()) + ".readExcel.exception....异常...异常信息:{}", e);
}
log.debug(UtilDateTime.getTimestamp(System.currentTimeMillis()) + ".readExcel.end...读取结束无异常");
}

posted @ 2017-04-14 17:06  望梦圆  阅读(268)  评论(0编辑  收藏  举报
https://meilishiyan-song.taobao.com/