BAOs Bais Significance

Source: Internet
Author: User

Import Java.io.bufferedinputstream;import Java.io.bytearrayinputstream;import Java.io.ByteArrayOutputStream; Import Java.io.ioexception;import Java.io.inputstream;import Org.junit.test;public class Testio { Bytearrayoutputstream BAOs = new Bytearrayoutputstream (), @Testpublic void Test1 () throws Exception {Process exec = Runtime . GetRuntime (). EXEC ("ipconfig"); InputStream InputStream = Exec.getinputstream (); byte[] bytes = new Byte[1024];int len = 0 ;//bytearrayinputstream Bais = new while ((Len=inputstream.read (bytes))!=-1) {//inputstream.read (bytes); Baos.write ( Bytes,0,len);} Baos.flush (); thread T1 = new Thread (new Runnable () {byte[] temp = new byte[1024];byte[] ByteArray = Baos.tobytearray (); Bytearrayinputstream Bais = new Bytearrayinputstream (ByteArray); Bufferedinputstream bis = new Bufferedinputstream (bais); int len=0; StringBuilder sb = new StringBuilder ();p ublic void Run () {//TODO auto-generated method Stubtry {while ((Len=bis.read (temp) ) {!=-1) {sb.append (new String (Temp,0,len));} System.out.println (Sb.tostring ());} catch (IOException e) {//TODO auto-generated catch Blocke.printstacktrace ();}}); Thread t2 = new Thread (new Runnable () {byte[] temp = new byte[1024];byte[] ByteArray = Baos.tobytearray (); Bytearrayinputstream Bais = new Bytearrayinputstream (ByteArray); Bufferedinputstream bis = new Bufferedinputstream (bais); int len=0; StringBuilder sb = new StringBuilder ();p ublic void Run () {//TODO auto-generated method Stubtry {while ((Len=bis.read (temp) ) {!=-1) {sb.append (new String (Temp,0,len));} System.out.println (Sb.tostring ());} catch (IOException e) {//TODO auto-generated catch Blocke.printstacktrace ();}}); T1.start (); T2.start ();}}

  

BAOs Bais Significance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.