whhxtt
发贴: 6
积分: 0
|
于 2006-03-30 09:44
对啊,那要怎样才可以呢?我对路径是一头雾水,一点都不懂。还有我这个程序也提示错误,就是我的路径写的有问题,错误是这样的:java.lang.Error: 无法解析的编译问题: 转义序列无效(有效的转义序列为 \b \t \n \f \r \" \' \\)
at xinhua.net.com.SequenceIuputStreamDemo.main(SequenceIuputStreamDemo.java:38) Exception in thread "main"
程序如下: package xinhua.net.com;
/** * @author Administrator * * TODO 要更改此生成的类型注释的模板,请转至 * 窗口 - 首选项 - Java - 代码样式 - 代码模板 */ import java.io.*; import java.util.*; class InputStreamEnumerator implements Enumeration{ private Enumeration files; public InputStreamEnumerator(Vector files){ this.files=files.elements(); } public boolean hasMoreElements(){ return files.hasMoreElements(); } public Object nextElement(){ try{ return new FileInputStream(files.nextElement().toString()); } catch(Exception e){ return null; } } } public class SequenceIuputStreamDemo { public static void main(String[]args)throws Exception{ int c; Vector files=new Vector(); files.addElement("D:\Downloads\eclipse\workspace\jsp\file1.txt"); files.addElement("D:\Downloads\eclipse\workspace\jsp\file2.txt"); InputStreamEnumerator w=new InputStreamEnumerator(files); InputStream input=new SequenceInputStream; while((c=input.read())!=-1){ System.out.println((char)c); } input.close(); } }
|