//源文件PipedStream.java
import java.lang.Thread;
import java.io.*;public class PipedStream
{   
public static void main(String[] args)
{
    try
    {
Thread t1=new Sender();
Thread t2=new Receiver();

PipedOutputStream outStream=t1.getOutputStream();//此处13行
PipedInputStream inStream=t2.getInputStream();//此处14行
outStream.connect(inStream);
t1.start();
t2.start();
    }
    catch(IOException e)
    {
     System.out.println(e.getMessage());
    }

}
}
class Sender extends Thread
{
private PipedOutputStream out=new PipedOutputStream();
public PipedOutputStream getOutputStream()
{
return out;
}
public void run()
{
try
{
String str=new String("Hello,Recerver!");
out.write(str.getBytes());
out.close();
}
catch(IOException e)
{
System.out.println(e.getMessage());
}
}

}
class Receiver extends Thread
{
private PipedInputStream in=new PipedInputStream();
public PipedInputStream getInputStream()
{
return in;
}
public void run()
{
String str=null;
byte[] bytes=new byte[1024];
try
{
int j=in.read(bytes);
str=new String(bytes,0,j);
System.out.println("Response:Copied!"+str);
        in.close();
}
catch(IOException e)
{
System.out.println(e.getMessage());

}

}
}
/*报错:E:\Java\myClass\FileOpe\PipedStream.java:13: 找不到符号
符号: 方法 getOutputStream()
位置: 类 java.lang.Thread
        PipedOutputStream outStream=t1.getOutputStream();
                                      ^
E:\Java\myClass\FileOpe\PipedStream.java:14: 找不到符号
符号: 方法 getInputStream()
位置: 类 java.lang.Thread
        PipedInputStream inStream=t2.getInputStream();
                                    ^
2 错误*/