本帖最后由 陈国柱 于 2013-9-17 20:01 编辑
在editplus编辑,用cmd运行也是没有问题的,不知道为什么移植到MyEclipse后,枚举那里的语句就出问题了,就运行不了,请求解答,谢谢- package day18to21;
- import java.io.*;
- import java.util.*;
- class SequenceDemo
- {
- public static void main(String[] args) throws IOException
- {
- Vector<FileInputStream> v = new Vector<FileInputStream>();
- v.add(new FileInputStream("1.txt"));
- v.add(new FileInputStream("2.txt"));
- v.add(new FileInputStream("3.txt"));
- Enumeration<!-- <FileInputStream> --> en = v.elements();//这里总是显示有错误,而且因为这一句运行不了
- SequenceInputStream sis = new SequenceInputStream(en);
- FileOutputStream fos = new FileOutputStream("4.txt");
- byte[] buf = new byte[1024];
- int len = 0;
- while ((len=sis.read(buf))!=-1)
- {
- fos.write(buf,0,len);
- }
- fos.close();
- sis.close();
- }
- }
复制代码 |
|