I/O

来源:互联网 发布:苹果手机数据恢复公司 编辑:程序博客网 时间:2024/06/06 00:15

一、输入流(读)

File file = new FIle(String path);

InputStream is = new FileInputStream(file);

FileOutputStream os = null;

os = new FileOutputStream(outfile);

byte[] b = new byte[1024];

int c;

String result="";

BASE64Encoder encoder = new BASE64Encoder();

/*  //对输入流加密

while((c=is.read(b))!=-1){

     result += encoder.encoder(b);

}

return result;
*/

 

while((c=is.read(b))!=-1){

     os.write(b, 0, c);

}

if(is !=null){
   try {
    is.close();
   } catch (IOException e) {
    e.printStackTrace();
   }
  }
  if(os!=null){
   try {
    os.close();
   } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
  }






原创粉丝点击