| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 451 人关注过本帖
标题:while((remain = fileInputStream.read()) != -1)
取消只看楼主 加入收藏
yu1543054075
Rank: 1
等 级:新手上路
帖 子:102
专家分:8
注 册:2015-4-30
结帖率:90.24%
收藏
已结贴  问题点数:20 回复次数:0 
while((remain = fileInputStream.read()) != -1)
import *;
public class FileStreamDemo {
    public static void main(String[] args) {
        try {
            byte[] buffer = new byte[1024];
            FileInputStream fileInputStream =
            new FileInputStream(new File(args[0]));
            FileOutputStream fileOutputStream =
            new FileOutputStream(new File(args[1]));
            System.out.println("复制档案:" +
            fileInputStream.available() + "字节");
            while(true) { // 从来源档案读取数据至缓冲区
                if(fileInputStream.available() < 1024) {
                    int remain;
                    while((remain = fileInputStream.read())
                    != -1) {
                        fileOutputStream.write(remain);
                    }
                    break;
                }
                else {
                    fileInputStream.read(buffer);
                    // 将数组数据写入目的档案
                    fileOutputStream.write(buffer);
                }
            }
            // 关闭串流
            fileInputStream.close();
            fileOutputStream.close();
            System.out.println("复制完成");
        }
        catch(ArrayIndexOutOfBoundsException e) {
            System.out.println(
            "using: java FileStreamDemo src des");
            e.printStackTrace();
        }
        catch(IOException e) {
            e.printStackTrace();
        }
    }
}
 int remain;
while((remain = fileInputStream.read())!= -1)
不明白是什么意思,求指导!!!
搜索更多相关主题的帖子: public import 
2015-06-14 20:55
快速回复:while((remain = fileInputStream.read()) != -1)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014924 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved