复习,真的可以动的很多,一开始我不懂的东西,现在懂了好多,就像这个实现ArrayList接口的这个例子,毕老师写的真好,
我用匿名内部类实现了下,这里和大家分享下,收益良多啊
public class test_11 {
public static void main(String[] args) throws IOException {
ArrayList<FileInputStream> vec=new ArrayList<>();
vec.add(new FileInputStream("d:\\001.avi"));
vec.add(new FileInputStream("d:\\000.avi"));
Iterator<FileInputStream> it=vec.iterator();
SequenceInputStream sequece=new SequenceInputStream(new Enumeration<FileInputStream>()
{
public boolean hasMoreElements() {
return it.hasNext();
}
@Override
public FileInputStream nextElement() {
return it.next();
}
}
);
PrintStream pri=new PrintStream(new FileOutputStream("d:"+File.separator+"4.avi"),true);
byte[] b=new byte[1024];
int len=0;
while((len=sequece.read(b))!=-1)
{
pri.write(b,0,len);
pri.flush();
}
pri.close();
sequece.close();
}
}
|