为什么用字节流读取写入文件会造成文件大小不一致?

dcq dcq 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的程序代码如下:
import java.io.*;

public class IOTest{
public static void main(String[] args){

try{

DataInputStream in2 = new DataInputStream(new BufferedInputStream(new FileInputStream("1.jpg")));
DataOutputStream out2= new DataOutputStream(new BufferedOutputStream(new FileOutputStream("2.jpg")));
while( in2.available()!=0)
out2.writeByte(in2.readByte());

}
catch(IOException e){}

}
}

我的想法是:从文件1.jpg产生一个DataInputStream,然后从此stream中读取数据写入2.jpg,结果2.jpg文件和1.jpg文件大小不致了,请问这是什么?
...全文
评论 10
收藏 已收藏
分享
返回顶部
dcq
Java SE 62,621 成员 307,251 内容