Java 8 PipedOutputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PipedOutputStream class.

This code example shows how to use the following methods:close
   
  private static boolean checkPrintAllValues(JMXGet jmx) throws Exception {
    int size = 0; 
    byte[] bytes = null;
    String pattern = "List of all the available keys:";
    PipedOutputStream pipeOut = new PipedOutputStream();
    PipedInputStream pipeIn = new PipedInputStream(pipeOut);
    System.setErr(new PrintStream(pipeOut));
    jmx.printAllValues();
    if ((size = pipeIn.available()) != 0) {
      bytes = new byte[size];
      pipeIn.read(bytes, 0, bytes.length);            
    } 
    pipeOut.close();
    pipeIn.close();
    return bytes != null ? new String(bytes).contains(pattern) : false;
  } 
   
  /** 
   * test JMX connection to DataNode.. 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
public class CompactObjectSerializationTest { 
 
    @Test
    public void testInterfaceSerialization() throws Exception {
        PipedOutputStream pipeOut = new PipedOutputStream();
        PipedInputStream pipeIn = new PipedInputStream(pipeOut);
        CompactObjectOutputStream out = new CompactObjectOutputStream(pipeOut);
        CompactObjectInputStream in = new CompactObjectInputStream(pipeIn, ClassResolvers.cacheDisabled(null));
        out.writeObject(List.class);
        Assert.assertSame(List.class, in.readObject());
    } 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:write, flush
 
  @Test 
  public void testRead() throws IOException, InterruptedException, TimeoutException, ExecutionException 
  { 
    final int pipeBufSize = 1024;
    final PipedOutputStream pos = new PipedOutputStream();
    final PipedInputStream pis = new PipedInputStream(pos, pipeBufSize);
 
    // We use twice the size of the pipe buffer to ensure that the first read 
    // will not get all bytes. We can't use more than twice the pipe buffer size 
    // because that the reader would effectively fall behind and pos.write(bytes) 
    // would block. 
    final byte[] bytes = new byte[2 * pipeBufSize];
 
    final ExecutorService exec = Executors.newSingleThreadExecutor();
    try 
    { 
      final Future<ByteString> result = exec.submit(new Callable<ByteString>()
      { 
        @Override 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:write, flush
 
  @Test
  public void testRead() throws IOException, InterruptedException, TimeoutException, ExecutionException
  { 
    final int pipeBufSize = 1024;
    final PipedOutputStream pos = new PipedOutputStream();
    final PipedInputStream pis = new PipedInputStream(pos, pipeBufSize);
 
    // We use twice the size of the pipe buffer to ensure that the first read 
    // will not get all bytes. We can't use more than twice the pipe buffer size 
    // because that the reader would effectively fall behind and pos.write(bytes) 
    // would block. 
    final byte[] bytes = new byte[2 * pipeBufSize];
 
    final ExecutorService exec = Executors.newSingleThreadExecutor();
    try 
    { 
      final Future<ByteString> result = exec.submit(new Callable<ByteString>()
      { 
        @Override 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, write
            fail("Test 1: IOException expected.");
        } catch (IOException e) {
            // Expected. 
        } 
 
        out = new PipedOutputStream(new PipedInputStream());
 
        try { 
            out.write(testString.getBytes(), -1, 10);
            fail("Test 2: IndexOutOfBoundsException expected.");
        } catch (IndexOutOfBoundsException e) {
            // Expected. 
        } 
 
        try { 
            out.write(testString.getBytes(), 0, -1);
            fail("Test 3: IndexOutOfBoundsException expected.");
        } catch (IndexOutOfBoundsException e) {
            // Expected. 
        } 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        if (iss == null)
             throw new IOException("No server for port: " + port);
        PipedInputStream cis = BigPipedInputStream.getInstance();
        PipedInputStream sis = BigPipedInputStream.getInstance();
        PipedOutputStream cos = new PipedOutputStream(sis);
        PipedOutputStream sos = new PipedOutputStream(cis);
        clientSock.setInputStream(cis);
        clientSock.setOutputStream(cos);
        iss.queueConnection(new InternalSocket(sis, sos));
    } 
 
    private void queueConnection(InternalSocket sock) throws IOException {
        if (!_running)
             throw new IOException("Server closed for port: " + _port);
        //if (_log.shouldLog(Log.DEBUG)) 
        //    _log.debug("Queueing " + _port); 
        try { 
            _acceptQueue.put(sock);
        } catch (InterruptedException ie) {}
    } 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:write, flush, write, sleep, PipedOutputStream.write
    private final KeyOperation backSpace =  new KeyOperation(Key.BACKSPACE, Operation.DELETE_PREV_CHAR);
 
    @Test
    public void testExportCompletionAndCommand() throws IOException, InterruptedException {
 
        PipedOutputStream outputStream = new PipedOutputStream();
        PipedInputStream pipedInputStream = new PipedInputStream(outputStream);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 
        Settings settings = new SettingsBuilder() 
                .terminal(new TestTerminal()) 
                .inputStream(pipedInputStream)
                .outputStream(new PrintStream(byteArrayOutputStream))
                .setPersistExport(false) 
                .logging(true) 
                .create(); 
 
         CommandRegistry registry = new AeshCommandRegistryBuilder().create();
 
        AeshConsoleBuilder consoleBuilder = new AeshConsoleBuilder()

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:connect
    /** 
     * @tests java.io.PipedOutputStream#connect(java.io.PipedInputStream) 
     */ 
    public void test_connectLjava_io_PipedInputStream_Exception() 
            throws IOException { 
        out = new PipedOutputStream();
        out.connect(new PipedInputStream());
        try { 
            out.connect(null);
            fail("should throw NullPointerException"); //$NON-NLS-1$
        } catch (NullPointerException e) {
            // expected 
        } 
    } 
 
    /** 
     * @tests java.io.PipedOutputStream#connect(java.io.PipedInputStream) 
     */ 
    public void test_connectLjava_io_PipedInputStream() { 
        try { 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:write, close
    reader.close();
  } 
 
  private void writeToPipe(String value) throws Exception {
    byte[] bytes = value.getBytes();
    output.write(bytes);
  } 
 
  @Test
  public void testReadLine() throws Exception {
    startReading(new ReadLine()); 
    writeToPipe("a line\r\n"); 
    finishReading(); 
    assertEquals("a line", readResult);
  } 
 
  @Test
  public void testReadLineBytes() throws Exception {
    startReading(new ReadLineBytes()); 
    writeToPipe("a line\r\n"); 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    } 
 
    @Test 
    public void shouldRoundTrip() throws IOException { 
        final PipedInputStream pipedInputStream = new PipedInputStream();
        final PipedOutputStream pipedOutputStream = new PipedOutputStream(pipedInputStream);
        final DataOutputStreamExtended outputImpl = new DataOutputStreamExtended(pipedOutputStream);
        final DataInputStreamExtended inputImpl = new DataInputStreamExtended(pipedInputStream);
 
        outputImpl.writeEncodable(encodable);
        final Object decodedEncodable = inputImpl.readEncodable(Object.class);
 
        assertRoundtripped(decodedEncodable, encodable);
    } 
 
    protected abstract void assertRoundtripped(Object decodedEncodable, Object originalEncodable);
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 PipedOutputStream Questions & Answers:

See Code Examples for Java 8 PipedOutputStream Methods: