当前位置: 首页 > news >正文

网站系统安全保护等级是必须做的手机怎么解除禁止访问网页

网站系统安全保护等级是必须做的,手机怎么解除禁止访问网页,音乐分享网站源码,天眼企业查询系统官网文章目录 java中try-with-resources自动关闭io流0 简要说明try-with-resources java中try-with-resources自动关闭io流 0 简要说明 在传统的输入输出流处理中#xff0c;我们一般使用的结构如下所示#xff0c;使用try - catch - finally结构捕获相关异常#xff0c;最后不… 文章目录 java中try-with-resources自动关闭io流0 简要说明try-with-resources java中try-with-resources自动关闭io流 0 简要说明 在传统的输入输出流处理中我们一般使用的结构如下所示使用try - catch - finally结构捕获相关异常最后不管是否有异常我们都将流进行关闭处理 try {//业务代码} catch (SQLException e) {// 异常数据回滚try {connection.rollback();} catch (SQLException ex) {log.error(ERROR_MSG, e);throw new IllegalArgumentException(e);}log.error(ERROR_MSG, e);throw new IllegalArgumentException(e);} finally {if (Objects.nonNull(preparedStatement)) {try {preparedStatement.close();} catch (SQLException e) {log.error(ERROR_MSG, e);throw new IllegalArgumentException(e);}}if (Objects.nonNull(connection)) {try {connection.close();} catch (SQLException e) {log.error(ERROR_MSG, e);throw new IllegalArgumentException(e);}}}try-with-resources 在jdk1.7之后推荐使用try() {} catch(IOException e){}的方式来处理io流它可以自动关闭流。如下所示是一个简单的按行读取文件内容的示例Testpublic void readFileContent() {File file new File(d://DumpStacks.log);try (BufferedReader reader new BufferedReader(new FileReader(file))) {String line;while ((line reader.readLine()) ! null) {log.info(line : 【{}】 , line);}} catch (IOException e) {log.error(error msg : 【{}】, e);throw new RuntimeException(e);}}抛异常情况 java.lang.RuntimeException: java.io.FileNotFoundException: d:\DumpStacks.log (系统找不到指定的文件。) at com.geekmice.springbootselfexercise.NoDaoTest.readFileContent(NoDaoTest.java:347) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)Caused by: java.io.FileNotFoundException: d:\DumpStacks.log (系统找不到指定的文件。) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.(FileInputStream.java:138) at java.io.FileReader.(FileReader.java:72) at com.geekmice.springbootselfexercise.NoDaoTest.readFileContent(NoDaoTest.java:340) 反编译之后可以看到自动关闭流操作 打开target找到对应字节码文件 Testpublic void readFileContent() {File file new File(d://DumpStascks.log);try {BufferedReader reader new BufferedReader(new FileReader(file));Throwable var3 null;try {String line;try {while((line reader.readLine()) ! null) {log.info(line : 【{}】, line);}} catch (Throwable var13) {var3 var13;throw var13;}} finally {if (reader ! null) {if (var3 ! null) {try {reader.close();} catch (Throwable var12) {var3.addSuppressed(var12);}} else {reader.close();}}}} catch (IOException var15) {log.error(error msg : 【{}】, var15);throw new RuntimeException(var15);}}当使用了try(){}代码块之后代码执行完毕就可以进行流的自动关闭比传统的方式简洁了不少。 try()这部分可以有多个语句语句之间分号隔开也可以同时包含输入流和输出流。最后执行完毕统一关闭。
http://www.zqtcl.cn/news/562586/

相关文章:

  • 九度网站建设网站做ppt模板
  • 浙江做公司网站多少钱评论回复网站怎么做
  • 江门网络建站模板虚拟主机价格一般多少钱
  • 网站建设公司云南深圳手机商城网站设计费用
  • 汇泽网站建设网页版快手
  • 手机销售培训网站wordpress案例插件
  • 滨江道做网站公司wordpress 花瓣网
  • 如何建网站快捷方式软件开发做平台
  • 常见的静态网页深圳罗湖企业网站优化
  • 做网站一天赚多少钱外贸网站建设排名
  • 一个大型网站建设得多少钱百度成都总部
  • 网站制作公司汉狮网络手机版网站优化
  • 铜川做网站logo 图标 设计
  • 如何做网站的注册页面南京宣传片公司有哪些
  • 中国建设机械教育协会网站网站建设中html中关于图片显示的标签有哪些
  • 网站过期后dede减肥网站源码
  • 营销型 手机网站网站建设方案后期服务
  • 怎么做一个个人网站建网站的八个步骤
  • 淘宝导购网站模版上海网站推广软件
  • 做影视网站引流湖北响应式网站建设费用
  • 网站统计cnzz网站空间有哪些
  • 泉州微信网站开发公司wordpress头像解决
  • 湛江网站建设皆选小罗24专业网站建设 福田
  • 厦门哪些做鲜花的网站门户网站开发设计报告
  • asp.net网站设计分工天津网站开发贴吧
  • 做多语言网站教程南宁vi设计公司
  • 百度联盟 网站备案wordpress 吾爱破解
  • 山西省建设厅网站首页网络营销推广为什么效果不好
  • 建材做网站好吗长沙做网站微联讯点不错
  • 建设小型网站分类门户网站系统