Code example for PipedInputStream

0
     
    public static DataNetSocketPair createDataNetSocketPair() throws IOException { 
        DataNetSocketPair result = new DataNetSocketPair(); 
         
        // create stream from higher layer 
        PipedInputStream fromHigherLayerIS = new PipedInputStream(); 
        PipedOutputStream fromHigherLayerOS = new PipedOutputStream(fromHigherLayerIS); 
         
        // stream to higher layer 
        PipedInputStream toHigherLayerIS = new PipedInputStream(); 
        PipedOutputStream toHigherLayerOS = new PipedOutputStream(toHigherLayerIS); 
 
        // create socket provided to higher layer 
        result.setSocket(new DataNetSocketImpl(toHigherLayerIS, fromHigherLayerOS)); 
        result.setInvertedSocked(new DataNetSocketImpl(fromHigherLayerIS, toHigherLayerOS)); 
         
        return result; 
    } 
} 
Experience pair programming with AI  Get Codota for Java