import java.io.*;
class PipeApp
{
public static void main(String[] args)
{
PipeApp pipeApp = new PipeApp();
try
{
FileInputStream AFileIn = new FileInputStream("input.txt");
InputStream BInPipe = pipeApp.changeToB(AFileIn);
InputStream CInPipe = pipeApp.changeToC(BInPipe);
System.out.println();
System.out.println("Here is the results:");
System.out.println();
BufferedReader inputStream = new BufferedReader(new InputStreamReader(CInPipe));
String str = inputStream.readLine();
while (str != null)
{
System.out.println(str);
str = inputStream.readLine();
}
inputStream.close();
}
catch (InterruptedException e)
{
System.out.println(e.toString());
}
}
public InputStream changeToB(InputStream inputStream)
{
try
{
BufferedReader AFileIn = new BufferedReader(new InputStreamReader(inputStream));
PipedOutputStream pipeOut = new PipedOutputStream();
PipedInputStream pipeIn = new PipedInputStream(pipeOut);
PrintStream printStream = new PrintStream(pipeOut);
Thread bThread = new Thread(AFileIn, printStream);
bThread.start();
return pipeIn;
}
catch (InterruptedException e)
{
System.out.println(e.toString());
}
return null;
}
public InputStream changeToC(InputStream inputStream)
{
try
{
BufferedReader BFileIn = new BufferedReader(new InputStreamReader(inputStream));
PipedOutputStream pipeOut2 = new PipedOutputStream();
PipedInputStream pipeIn2 = new PipedInputStream(pipeOut2);
PrintStream printStream2 = new PrintStream(pipeOut2);
Thread cThread = new Thread(BFileIn, printStream2);
cThread.start();
return pipeIn2;
}
catch (InterruptedException e)
{
System.out.println(e.toString());
}
return null;
}
}
I keep getting an error on the two lines that are:
Thread bThread = new Thread(AfileIn, printStream2);
and
Thread cThread = new Thread(BfileIn, printStream2);
when I compile it gives me an error about the "new" it says:
cannot resolve symbol...
I may have messed up elsewhere but I remember being told that the first error is usually the error and those are the only two errors I get.
Can anyone assist me,
Thanks
Kim