package com.throwsss;

 import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream; class Picture{
public static void readWrite(){
File file = new File("D://abc.jpg");
File file2 = new File("F://abc.jpg");
InputStream inputStream = null;
FileOutputStream fileOutputStream = null;
try {
inputStream = new FileInputStream(file);
fileOutputStream = new FileOutputStream(file2);
byte[] bs = new byte[1024];
int length = 0;
try {
while((length = inputStream.read(bs))!=-1){
fileOutputStream.write(bs, 0, length);
}
} catch (IOException e) {
// TODO Auto-generated catch block
throw new RuntimeException(e);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
throw new RuntimeException(e);
}finally{
if(fileOutputStream != null){
try {
fileOutputStream.close();
System.out.println("关闭输出流资源成功...");
} catch (IOException e) {
System.out.println("关闭输出流资源失败...");
throw new RuntimeException(e);
}finally{
if(inputStream != null){
try {
inputStream.close();
System.out.println("关闭输入流对象成功...");
} catch (IOException e) {
System.out.println("关闭输入流对象失敗...");
throw new RuntimeException(e);
}
}
}
}
} }
} public class Throwtest { public static void main(String[] args) {
// TODO Auto-generated method stub Picture picture = new Picture();
picture.readWrite();
} }

IO异常 的处理 test的更多相关文章

  1. 分享一个异步任务在遇到IO异常时支持递归回调的辅助方法

    public void TryAsyncActionRecursively<TAsyncResult>( string asyncActionName, Func<Task<T ...

  2. java.sql.SQLException: Io 异常: Connection reset

    当数据库连接池中的连接被创建而长时间不使用的情况下,该连接会自动回收并失效,但客户端并不知道,在进行数据库操作时仍然使用的是无效的数据库连接,这样,就导致客户端程序报“ java.sql.SQLExc ...

  3. java.sql.SQLException: Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=186646784)(ERR=12505)(ERR

    dbc 链接orcal出错 java.sql.SQLException: Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=186646784)( ...

  4. 数据库连接报错之IO异常(The Network Adapter could not establish the connection)

    Io 异常: The Network Adapter could not establish the connection 有以下四个原因: 1.oracle配置 listener.ora 和tnsn ...

  5. spring+ibatis问题1—— 程序报错:java.sql.SQLException: Io 异常: Connection reset by peer, socket write error; ”或“java.sql.SQLException 关闭的连接”异常

    转自:http://blog.sina.com.cn/s/blog_1549fb0710102whz2.html spring+ibatis程序测试时报错:java.sql.SQLException: ...

  6. Io 异常: The Network Adapter could not establish the connection

    新接触一个项目,导入源码,在本地启动的时候后台报了一个错误: Could not discover the dialect to use. java.sql.SQLException: Io 异常: ...

  7. IO 异常:The Network Adapter could not establish the connection 怎么解决

    IO 异常:The Network Adapter could not establish the connection 怎么解决

  8. Flutter采坑之路 用真机跑起来的时候提示 initGradle失败,IO异常,downloading Gradle-4.6-all.zip失败

    这个异常就是Gradle下载异常,进而下面会提示一行IO异常 我这里的原因就是Gradle对应的4.6-all版本下载不下来(一般情况下确实很难下载下来) 所以在正常AS工程呢,我们选择一下Gradl ...

  9. linux xfs的一次io异常导致的crash

    returned. [ blocked seconds.----这个默认是120,该环境上是被人为设置1200 [8556407.425653] "echo 0 > /proc/sys ...

  10. Android HttpURLConnection.connect找不到源 HttpURLConnection连接失败 HttpURLConnection.connect IO异常 解决办法

    Android HttpURLConnection.connect找不到源  HttpURLConnection连接失败 HttpURLConnection.connect IO异常 解决办法 以下代 ...

随机推荐

  1. spring cloud gateway之filter篇

    转载请标明出处: https://www.fangzhipeng.com 本文出自方志朋的博客 在上一篇文章详细的介绍了Gateway的Predict,Predict决定了请求由哪一个路由处理,在路由 ...

  2. 20155237 《Java程序设计》实验一(Java开发环境的熟悉)实验报告

    20155237 <Java程序设计>实验一(Java开发环境的熟悉)实验报告 一.实验内容及步骤 使用JDK编译.运行简单的java程序 新建文件夹 打开终端 输入cd Code命令进入 ...

  3. stat命令的实现-mysate 20155239吕宇轩

    stat命令的实现-mysate 20155239吕宇轩 学习使用stat(1),并用C语言实现 提交学习stat(1)的截图 man -k ,grep -r的使用 伪代码 产品代码 mystate. ...

  4. JavaEE笔记(四)

    sql的完整顺序完整的sql语句,由6个子句组成1. from2. where3. group by4. select5. having6. order by # having 和 where的区别w ...

  5. 【转载】COM 组件设计与应用(九)——IDispatch 接口 for VC6.0

    原文: http://vckbase.com/index.php/wv/1224.html 一.前言 终于写到了第九回,我也一直期盼着写这回的内容耶,为啥呢?因为自动化(automation)是非常常 ...

  6. Codeforces 914 C 数位DP+暴力打表+思维

    题意 给出一个二进制数\(n\),每次操作可以将一个整数\(x\)简化为\(x\)的二进制表示中\(1\)的个数,如果一个数简化为\(1\)所需的最小次数为\(k\),将这个数叫做特殊的数, 问从\( ...

  7. UWP DEP0700: 应用程序注册失败。[0x80073CF9] Install failed. Please contact your software vendor. (Exception from HRESULT: 0x80073CF9)

    现在部署的app项目八成是从以前的一个项目复制过来,修改的.或者本地存在一个相同的app没有卸载. 解决方法: 1. 卸载之前相同的app 2.如果是复制的项目A,但是经过修改后变成了项目B,并且A和 ...

  8. xaf.domain object new 在属性上的用法

    有如下业务对象定义: using System; using System.Linq; using System.Text; using DevExpress.Xpo; using DevExpres ...

  9. .NET:关于数据模型、领域模型和视图模型的一些思考

    背景 数据模型.领域模型和视图模型是“模型”的三种角色,一些架构用一种类型表示这三种角色,如:传统三层架构.也有一些架构用两种类型表示这三种角色,如:结合ORM的领域驱动架构.非常少见的场景是用三种类 ...

  10. Ubuntu根目录下各文件夹的作用

    Ubuntu上常识和常用命令: 1.Ubuntu文件结构 在ubuntu上硬盘的目录和Windows上不同,Windows可以根据自己的需求分不同的盘符,但ubuntu上只有一个盘,从根目录开始每个目 ...