天堂向右,我依然向左

天下之大,虽离家千里,何处不可往!何事不可为!
生活之路,纵坎坷曲折,当奋斗不息,则精彩纷呈!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

 

代码
  android.util.Base64OutputStream stream;
  File file 
= new File(Environment.getExternalStorageDirectory()
    .getPath()
    
+ "/GooglePinyinInstaller.exe");
  
// 合并的文件
  File outFile = new File(Environment.getExternalStorageDirectory()
    .getPath()
    
+ "/GooglePinyinInstaller2.exe");

  
// 缓冲
  byte[] buffer = new byte[1024 * 1024];

  
try {
   
// 输入流
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   stream 
= new Base64OutputStream(out, android.util.Base64.CRLF
     
| android.util.Base64.NO_CLOSE);

   
// 输出流写进文件
   
// RandomAccessFile outt = new RandomAccessFile(outFile, "rw");
   int off = 0;

   
// 循环读取输入流 begin
   InputStream inn = new FileInputStream(file);
   
   
while (inn.read(buffer) != -1) {
    Log.d(TAG, 
"****" + off++);

    
// 写入流
    stream.write(buffer);
    
//
    
    
// 写入文件
    
//outt.write(out.toByteArray());

    
// 循环读取输入流 end
   }
   
   System.out.println(
new String(out.toByteArray()));

   out.close();
   stream.close();
//   outt.close();

  } 
catch (FileNotFoundException e) {
   e.printStackTrace();
  } 
catch (IOException e) {
   e.printStackTrace();
  }

 

 

posted on 2010-11-25 12:02  老舟  阅读(1121)  评论(0编辑  收藏  举报