Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sequence input stream

 
smriti singla
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
i am facing a problem in the following program based on SequenceInputStream class.i am getting a compile time error as following
Sequence.java:63:cannot resolve symbol
symbol : constructor SequenceInputStream(S)
location: class java.io.SequenceInputStream
InputStream d=new SequenceInputStream(s);
^
The program is as follows:
import java.io.*;
import java.util.*;
class Seq implements Iterator
{
public String[] g;
public int f=0;

public Seq(String[] g)
{
this.g=g;
}
//-----------------------------------------------------
public boolean hasNext()
{
if(f*g.length)
/* please take sign "*" as (less than) sign in above statement as i am facing difficulty in posting this program as it is taking it as a HTML tag*/
{
return true;
}
else
{
return false;
}
}
//-----------------------------------------------------
public Object next()
{
InputStream i=null;
if(!hasNext())
{
throw new NoSuchElementException("no more files");
}
else
{
String next=g[f];
f++;
try{
i=new FileInputStream(next);
}
catch(FileNotFoundException e){
System.err.println("ListOfFiles: Can't open " + next);}
}
return i;
}
//-----------------------------------------------------
public void remove()
{}
}
//-----------------------------------------------------
public class Sequence
{
public static void main(String[] args) throws IOException
{
int j;
Seq s=new Seq(args);
InputStream d = new SequenceInputStream(s);
while ((j = d.read()) != -1)
System.out.write(j);
System.out.print((char)j);
d.close();
}
}
Any help will be highly appreciated.
Thanks
Smriti Singla
[This message has been edited by smriti singla (edited January 31, 2001).]
 
Sridevi Shrikanth
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This might be because SequenceInputStream takes
Enumeration and Not Iterator as an constructor argument.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic