import java.net.*;
import java.io.*;public class client
{
static public PipedInputStream input = new PipedInputStream();
static public PipedOutputStream output = new PipedOutputStream(); static public byte[] buffer = new byte[10];
public static void main(String[] args)
{ try{
input.connect(output );
}catch (IOException ex) {
System.out.println("connection"+ex);
}
new Thread()
{
public void run()
{
buffer[0]='0';
buffer[1]='1';
buffer[2]='2'; while(true)
{
try{
output.write(buffer,0,3);
}
catch(IOException e)
{
System.out.println("------------------"+e); } }
}
}.start();
new Thread()
{
public void run()
{
while( true ){
try{
input.read( buffer, 0, 3);
System.out.println(new String(buffer));
}catch (IOException ex) {
System.out.println("------------------"+ex);
}
}
}
}.start();
}
}
import java.io.*;public class client
{
static public PipedInputStream input = new PipedInputStream();
static public PipedOutputStream output = new PipedOutputStream(); static public byte[] buffer = new byte[10];
public static void main(String[] args)
{ try{
input.connect(output );
}catch (IOException ex) {
System.out.println("connection"+ex);
}
new Thread()
{
public void run()
{
buffer[0]='0';
buffer[1]='1';
buffer[2]='2'; while(true)
{
try{
output.write(buffer,0,3);
}
catch(IOException e)
{
System.out.println("------------------"+e); } }
}
}.start();
new Thread()
{
public void run()
{
while( true ){
try{
input.read( buffer, 0, 3);
System.out.println(new String(buffer));
}catch (IOException ex) {
System.out.println("------------------"+ex);
}
}
}
}.start();
}
}
import java.io.*;public class client
{
static public PipedInputStream input = new PipedInputStream();
public static void main(String[] args)
{
try{
input.connect( aa.output );
new aa().start();/////////////////////////study_body添加
}catch (IOException ex) {
System.out.println("connection"+ex);
} new Thread()
{
public void run()
{
while( true ){
try{
byte[] buffer = new byte[1];
input.read( buffer, 0, 1 );
System.out.println(new String(buffer));
}catch (IOException ex) {
System.out.println("------------------"+ex);
}
}
}
}.start();
}
}====================================================================
package test;import java.net.*;
import java.io.*;public class aa extends Thread
{
static public PipedOutputStream output = new PipedOutputStream();
public void run()
{
while( true ){
try{
output.write( new String("hello world").getBytes(), 0, new String("hello world").getBytes().length);
System.out.println("a");
}catch (IOException ex) {
System.out.println(ex);
}
}
} public static void main(String[] args){
try{
output.connect( client.input );
}catch (IOException ex) {
System.out.println("connection"+ex);
} new aa().start();
}
}
================================================================