package com.itheima;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.io.IOException;
public class IoExc {
public static void main(String[] args)
{
int x=0;
while(x<3)
{++x;
System.out.print(x);
}
try {
Test();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
public static void Test()throws IOException
{
FileInputStream fis=new FileInputStream("D:\\1111.jpg");
FileOutputStream fos=new FileOutputStream("D:\\23.jpg");
ArrayList<FileInputStream> al=new ArrayList<FileInputStream>();
for(int x=0;x<4;x++)
al.add(new FileInputStream("d:\\"+x+".jpg"));
final Iterator<FileInputStream> ia=al.iterator();
Enumeration<FileInputStream> en=new Enumeration<FileInputStream>()
{
public boolean hasMoreElements()
{
return ia.hasNext();
}
public FileInputStream nextElement()
{
return ia.next();
}
};
SequenceInputStream ss=new SequenceInputStream(en);
byte[] bytes=new byte[1024*200];
int kk=0;
while((kk=ss.read(bytes))!=-1)
{
fos.write(bytes, 0, kk);
}
ss.close();
fos.close();
}
} |
|