如何将Line logger.severe记录到文件中。我只是在控制台中看到它。 顺便说一下,请问另一个问题,那就是你怎么能在严重事件之后跳过这一行,我试着继续,但它只是跳到下一栏...... 感谢您抽出宝贵时间提供帮助
private Product2 readProductRow(XSSFSheet ws, int r) throws SQLException
{
Product2 p = new Product2();
try
{
XSSFRow rowData = ws.getRow(r);
for (int j = 0; j < 5; j++) {
// read the first rcord
XSSFCell cell = rowData.getCell(j);
java.util.Date val = null;
String value = null;
FormulaEvaluator evaluator = ws.getWorkbook().getCreationHelper().createFormulaEvaluator();
if (cell !=null) {
switch (evaluator.evaluateFormulaCell(cell)) {
case Cell.CELL_TYPE_BOOLEAN:
value = cellToString(cell);
break;
case Cell.CELL_TYPE_NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
val = cell.getDateCellValue();
}
break;
case Cell.CELL_TYPE_STRING:
value = cellToString(cell);
break;
case Cell.CELL_TYPE_BLANK:
break;
case Cell.CELL_TYPE_ERROR:
break;
case Cell.CELL_TYPE_FORMULA:
value = cellToString(cell);
break;
}
if (value == null && val == null)
{
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC && DateUtil.isCellDateFormatted(cell)) {
val = cell.getDateCellValue();
}
else
value = cellToString(cell);
}
if (value == null && val == null)
{
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC && DateUtil.isCellDateFormatted(cell)) {
val = cell.getDateCellValue();
}
}
switch (j)
{
case 0:
if (value == null || value.toString().trim().equals(""))
{
logger.severe("第"+ r + "行纪录没有大类编码,没有汇入" );
continue;
}
else
{
char tid = db.getCategoryID(value.charAt(0));
if (tid == 'X')
{
db.insertCategory(value.charAt(0));
Category tex = db.getCategory(value);
tid = tex.getCode();
}
p.setCategoryID(tid);
t = tid;
}
break;
case 1:
if (value == null || value.toString().trim().equals(""))
{
答案 0 :(得分:1)
跳到下一行?使用return null;
或return rowData;
退出您的功能