java 事务处理 try catch_关于JAVA的异常处理try catch

publicvoidFileEn(StringfileReadPath,StringfileWritePath,Stringpassword,intlength){FilefileRead=newFile(fileReadPath);FilefileWrite=newFile(fileWritePath);if(!fileRead.exi...

public void FileEn(String fileReadPath,String fileWritePath,String password,int length){

File fileRead=new File(fileReadPath);

File fileWrite=new File(fileWritePath);

if(!fileRead.exists())

{

System.out.println("文件不存在");

System.exit(0);

}

if(!fileWrite.exists()){

System.out.println("创建文件");

try {

fileWrite.createNewFile();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

/* 下面怎么写try catch */

FileInputStream fins=new FileInputStream(fileRead);

FileOutputStream fous=new FileOutputStream(fileWrite);

byte[] data=new byte[fins.available()]; //读取图片的整个长度

int HeadLength=623; //jpg头部信息的长度

byte[] head=new byte[HeadLength];

byte[] temp=new byte[16];//由于AES是十六的倍数才能加密,不够的话会自动填充字段,即PKCS5Padding处理

byte[] end;

int len;

int readLen;

len=fins.read(data);

fins.close();

for(int i=0;i

head[i]=data[i];//读取头部信息

fous.write(head);

readLen=HeadLength;//表示当前读取的位置

while((readLen+16)

for(int j=0;j<16;j++)//每16个字节读取

temp[j]=data[readLen+j];

fous.write(encrypt(temp, password, length));//进行加密并且写入

readLen+=16;//当前读取位置+16

}

end=new byte[len-readLen];

for(int k=0;k

end[k]=data[readLen+k];

fous.write(end);

//对于最后小于16的字段不加直接写入,是为了避免PKCS5Padding

fous.close();

}

下面那里怎么写try catch 一直报错啊,万分感谢!!!

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值