java吧 关注:1,273,609贴子:12,783,969
  • 11回复贴,共1

用Buffered复制文件为何复制后的文件MD5码变了?

只看楼主收藏回复



1楼2015-09-01 16:46回复
    代码如下:
    class CopyFile {
    public static void FileCopy(String readfile, String writeFile) {
    try {
    BufferedInputStream bis = new BufferedInputStream(new FileInputStream(readfile));
    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(writeFile));
    byte [] b = new byte[65535];
    int bread ;
    Long start = System.currentTimeMillis();
    while ((bread = bis.read(b)) != -1) {
    //System.out.println(bread);
    bos.write(b);
    //read1 = bis.read(b);
    }
    bos.flush();
    bis.close();
    bos.close();
    System.out.println((System.currentTimeMillis() - start)+" milliseconds");
    } catch (IOException e) {
    System.out.println(e);
    }
    }


    2楼2015-09-01 16:47
    回复
      2025-08-12 10:14:34
      广告
      不感兴趣
      开通SVIP免广告


      3楼2015-09-01 16:48
      回复
        把那个65535改成1之后md5码不变了,但是速度慢了好多


        4楼2015-09-01 16:48
        回复
          把while中后面改为大于0 write后改为 b 0 bread


          来自手机贴吧5楼2015-09-01 17:43
          收起回复


            6楼2015-09-01 17:58
            收起回复
              轻插楼上菊花


              IP属地:上海7楼2015-09-01 20:01
              收起回复
                开发者提供了捕捉、回放、编解码等工具,


                8楼2015-09-01 20:58
                收起回复