import java.io.*;
class Piped1{
public static void main(String[] args)throws Exception{
PipedOutputStream pos=new PipedOutputStream();
PipedInputStream pis=new PipedInputStream();
try{
pos.connect(pis);
new Your(pos).start();
new MyThread(pis).start();
}catch(Exception e){
e.printStackTrace();
}
}
}
class Your extends Thread{
private PipedOutputStream pos;
Your(PipedOutputStream pos){
this.pos=pos;
}
public void run()
{
try{
pos.write("www.java.sun.com".getBytes());
pos.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
class MyThread extends Thread{
private PipedInputStream pis;
MyThread(PipedInputStream pis){
this.pis=pis;
}
public void run(){
try{
byte[] buf=new byte[1024];
int len=pis.read(buf);
// System.out.println(new String(buf,0,len));
System.out.println("HELLO");
}catch(Exception e){
e.printStackTrace();
}
}
}