Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 谁能帮我解决这个流的大问题 ?
snooopy





发贴: 23
积分: 0
于 2005-10-13 00:47 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我写了这两个程序 ,,

//  将一个jpg的文件分解一个文件成每个10k大的文件 !
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class Rmp3 {
static int index = 0;
public static void CreateNew(FileInputStream FIS) throws Exception {
File F = new File("C:\\tmp\\"+"no"+ index++ +".jpg");
byte [] buf = new byte[10240];
while( FIS.read(buf) != -1){
FileOutputStream FOS = new FileOutputStream(F);
for (int i=0;i<buf.length;i++){
if (buf[i] != 0){
FOS.write(buf[i]);
}
}
if ( FIS.available() != -1){
CreateNew(FIS);
}
}
}

public static void main(String[] args) throws Exception{
File F = new File("C:\\tmp\\therock01.jpg");
FileInputStream FIS = new FileInputStream(F);
CreateNew(FIS);
FIS.close();
}
}


 // 将分解的文件进行合并
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class AddFind {
public static void find(File F) throws Exception {
if (F.getName().endsWith(".jpg")){

FileInputStream FIS = new FileInputStream(F);
CreateNew(FIS);
} else {
File [] Fa = F.listFiles();
for (int i=0;i<Fa.length;i++){
find(Fa[i]);
}
}
}
public static void CreateNew(FileInputStream FIS) throws Exception {
byte [] buf = new byte [FIS.available()];
File FF = new File("C:\\tmp\\two.jpg");
while( (FIS.read(buf)) != -1){
FileOutputStream FOS = new FileOutputStream(FF,true);
for (int i=0;i<buf.length;i++){
if (buf[i] != 0){
FOS.write(buf[i]);
}
}
FOS.close();
}
}
public static void main(String[] args) throws Exception{
File F = new File("C:\\tmp\\bb\\jpg\\");
find(F);
}
}


问题 : 我将一个therock01.jpg,379k的文件分解了,分解后是38个文件
但合并的时候,文件却打不开,也就是two.jpg,合并后只是376k而已 ?
1:为什么会出现这样的情况,是否jpg不能用我这样的操作方式 ?
2:为什么我用分解和合并出来的文件容量大小都不一样 ? 合并后的文件少了什么 ?
3:我另外用了一个mp3的做了实验,结果是:原先是7.13m的mp3,分解合并后是7.06m ?我这样的操作方式同样可以用在mp3上吗 ?




话题树型展开
人气 标题 作者 字数 发贴时间
3320 谁能帮我解决这个流的大问题 ? snooopy 2351 2005-10-13 00:47
2740 Re:谁能帮我解决这个流的大问题 ? snowbug 138 2005-10-13 23:43

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923