如何高效学习Java基础——蜗牛版第五讲?

2026-06-09 02:272阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计283个文字,预计阅读时间需要2分钟。

如何高效学习Java基础——蜗牛版第五讲?

异常及日志。一、异常定义了自己定义了一个异常、1、运行时异常:可以使用逻辑代码进行控制、直接父类是RuntimeExpection;2、检查时异常:必须使用try-catch块、直接父类是Expection。日志:Logger.log

异常及日志.

一、异常、自己定义了一个异常、

1、运行时异常:可以自己用逻辑代码进行控制、直接父类是RuntimeExpection

2、检查时异常:必须try-catch块、直接父类是Expection

如何高效学习Java基础——蜗牛版第五讲?

日志:

Logger

log4j.rootLogger=debug,logfile,stdout 1、输出级别 2、介质名称 3、标准输出、向两个介质输出

public static void deleteFile(File file) throws FileOperationExpection {Logger logger = Logger.getLogger(FileIoUtil.class);if (!file.exists())throw new FileOperationExpection("文件不存在");if (file.isDirectory())throw new FileOperationExpection("不是文件");logger.debug("执行删除" + file.getName() + "文件");file.delete();}public static void main(String[] args) {try {FileIoUtil.deleteFile(new File("G:\\t.txt"));} catch (FileOperationExpection e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}

蜗牛—Java基础之学习(五),布布扣,bubuko.com

本文共计283个文字,预计阅读时间需要2分钟。

如何高效学习Java基础——蜗牛版第五讲?

异常及日志。一、异常定义了自己定义了一个异常、1、运行时异常:可以使用逻辑代码进行控制、直接父类是RuntimeExpection;2、检查时异常:必须使用try-catch块、直接父类是Expection。日志:Logger.log

异常及日志.

一、异常、自己定义了一个异常、

1、运行时异常:可以自己用逻辑代码进行控制、直接父类是RuntimeExpection

2、检查时异常:必须try-catch块、直接父类是Expection

如何高效学习Java基础——蜗牛版第五讲?

日志:

Logger

log4j.rootLogger=debug,logfile,stdout 1、输出级别 2、介质名称 3、标准输出、向两个介质输出

public static void deleteFile(File file) throws FileOperationExpection {Logger logger = Logger.getLogger(FileIoUtil.class);if (!file.exists())throw new FileOperationExpection("文件不存在");if (file.isDirectory())throw new FileOperationExpection("不是文件");logger.debug("执行删除" + file.getName() + "文件");file.delete();}public static void main(String[] args) {try {FileIoUtil.deleteFile(new File("G:\\t.txt"));} catch (FileOperationExpection e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}

蜗牛—Java基础之学习(五),布布扣,bubuko.com