我java.util.logging
用于记录许多文件操作(如复制、删除、移动、mkdir)。下面是一个示例复制作业:
try {
LOGGER.log(Level.FINE, "Copying Binary [ {0} ] to SDCard folder [ {1} ]", new Object[]{src, dst});
org.apache.commons.io.FileUtils.copyFileToDirectory(src, dst);
// append "..Ok" to previous log message
}
catch ( FileNotFoundException e ) {
LOGGER.log(Level.WARNING, "FileNotFoundException: Binary ["+ src.getAbsolutePath() + "] is missing");
}
catch (IOException e) {
LOGGER.log(Level.WARNING, "IOException: Binary [" + src.getAbsolutePath() + "] is unaccessible");
}
是否可以将文本附加..Ok
到以前的日志消息中?所以输出会说:
FINE: Copying Binary [ C:\dir\sub\a.bin ] to SDCard [ Y:\SDCard ] ..OK