PipedInputStream close - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PipedInputStream close method.

This code example shows how to use the following methods:available, close, read
  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.. 
   * @throws Exception  
8
CodeRank
This code example shows how to use the following methods:available, close, read
  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.. 
   * @throws Exception  
7
CodeRank
This code example shows how to use the following methods:close, connect, read, sleep
            } 
        } 
    } 
 
    public void test_read_after_write_close() throws Exception{ 
        PipedInputStream in = new PipedInputStream();
        PipedOutputStream out = new PipedOutputStream();
        in.connect(out);
        Thread worker = new Worker(out);
        worker.start();
        Thread.sleep(2000);
        assertEquals("Should read 20.", 20, in.read());
        worker.join();
        assertEquals("Write end is closed, should return -1", -1, in.read());
        byte[] buf = new byte[1];
        assertEquals("Write end is closed, should return -1", -1, in.read(buf, 0, 1));
        assertEquals("Buf len 0 should return first", 0, in.read(buf, 0, 0));
        in.close();
        out.close();
    } 

5
CodeRank
This code example shows how to use the following methods:close
	} 
 
	private <T> T cloneObj(T t) throws IOException {
		Serializer<T> keySerializer;
		Class<T> keyClass;
		PipedInputStream pis = new PipedInputStream();
		PipedOutputStream pos = new PipedOutputStream(pis);
		keyClass = (Class<T>) t.getClass();
		keySerializer = serializationFactory.getSerializer(keyClass);
		keySerializer.open(pos);
		keySerializer.serialize(t);
		Deserializer<T> keyDesiralizer = serializationFactory.getDeserializer(keyClass);
		keyDesiralizer.open(pis);
		T clonedArg0 = keyDesiralizer.deserialize(null);
		pos.close();
		pis.close();
		keySerializer.close();
		keyDesiralizer.close();
		return clonedArg0;
 
	} 
5
CodeRank
This code example shows how to use the following methods:close
        return bis.read();
    } 
 
    @Override 
    public void close() throws IOException { 
        bis.close();
    } 
 
    @Override 
    public int available() throws IOException { 
        return bis.available();
    } 
 
} 
4
CodeRank
This code example shows how to use the following methods:close
    } 
 
    public void close() throws IOException { 
        reader.close();
        osw.close();
        pis.close();
    } 
} 
4
CodeRank
This code example shows how to use the following methods:close
				e.printStackTrace();
			} 
		} 
		if (pin != null) {
			try { 
				pin.close();
			} catch (IOException e) {
				e.printStackTrace();
			} 
		} 
		if (dout != null) {
			try { 
				dout.close();
			} catch (IOException e) {
				e.printStackTrace();
			} 
		} 
		if (pout != null) {
			try { 
				pout.close();
4
CodeRank
This code example shows how to use the following methods:close
				e.printStackTrace();
			} 
		} 
		if (pin != null) {
			try { 
				pin.close();
			} catch (IOException e) {
				e.printStackTrace();
			} 
		} 
	} 
} 
4
CodeRank
This code example shows how to use the following methods:close
This code example shows how to use the following methods:close, connect
	/** 
	 * @tests java.io.PipedInputStream#close() 
	 */ 
	public void test_close() throws IOException { 
		// Test for method void java.io.PipedInputStream.close() 
		pis = new PipedInputStream();
		pos = new PipedOutputStream();
        pis.connect(pos);
        pis.close();
		try { 
			pos.write((byte) 127);
            fail("Failed to throw expected exception");
		} catch (IOException e) {
			// The spec for PipedInput saya an exception should be thrown if 
			// a write is attempted to a closed input. The PipedOuput spec 
			// indicates that an exception should be thrown only when the 
			// piped input thread is terminated without closing 
			return; 
		} 
	} 
5
CodeRank
close Method Overview
Closes this piped input stream and releases any system resources associated with the stream.
See Code Examples for other Java 8 PipedInputStream Methods: