如何将InputStream写入一个File?谢谢各位高手指教

解决方案 »

  1.   

    InputStream in = new FileInputStream(src);
            OutputStream out = new FileOutputStream(dst);
        
            byte[] buf = new byte[1024];
            int len;
            while ((len = in.read(buf)) > 0) {
                out.write(buf, 0, len);
            }
            in.close();
            out.close();
      

  2.   

    操作I/O的时候注意使用独立于UI的线程
      

  3.   

    同意楼上2位,最好再缓冲一下,用bufferedOutputStream