我用切割文件,把一个图片切成了很多part,在合并这些part的时候
看了一眼毕老师的代码- package days16;
- import java.io.*;
- import java.util.*;
- public class Spilt2
- {
- public static void main(String[]args) throws FileNotFoundException, IOException
- {
- ArrayList<FileInputStream> al = new ArrayList<FileInputStream>();
- for(int x=1; x<=49333; x++)
- {
- al.add(new FileInputStream("D:\\split\\"+x+".part"));
- }
- final Iterator<FileInputStream> it = al.iterator();
- Enumeration<FileInputStream> en = new Enumeration<FileInputStream>()
- {
- public boolean hasMoreElements()
- {
- return it.hasNext();
- }
- public FileInputStream nextElement()
- {
- return it.next();
- }
- };
- SequenceInputStream sis = new SequenceInputStream(en);
- FileOutputStream fos = new FileOutputStream("d:\\修.gif");
- byte[] buf = new byte[1024];
- int len = 0;
- while((len=sis.read(buf))!=-1)
- {
- fos.write(buf,0,len);
- }
- fos.close();
- sis.close();
- }
- }
复制代码 其中这段没看懂是为什么,希望有人帮我解释一下。。。- final Iterator<FileInputStream> it = al.iterator();
- Enumeration<FileInputStream> en = new Enumeration<FileInputStream>()
- {
- public boolean hasMoreElements()
- {
- return it.hasNext();
- }
- public FileInputStream nextElement()
- {
- return it.next();
- }
- };
复制代码 而且我为啥将打碎的图片的part,合并成一个新的图片,新的图片为什么已经破坏了。图片格式是从[.gif=>.gif]
|