MCPcopy Create free account
hub / github.com/DuGuQiuBai/Java / ArrayStreamDemo

Class ArrayStreamDemo

day22/code/day22_IO/src/cn/itcast_05/ArrayStreamDemo.java:12–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10 * ByteArrayOutputStream
11 */
12public class ArrayStreamDemo {
13 public static void main(String[] args) throws IOException {
14 // public ByteArrayOutputStream()
15 ByteArrayOutputStream baos = new ByteArrayOutputStream();
16 baos.write("helloworld".getBytes());
17 baos.write("javajava".getBytes());
18 baos.write("android".getBytes());
19 baos.close();
20
21 // public byte[] toByteArray()
22 byte[] bys = baos.toByteArray();
23
24 // public ByteArrayInputStream(byte[] buf)
25 ByteArrayInputStream bais = new ByteArrayInputStream(bys);
26 int by = 0;
27 while ((by = bais.read()) != -1) {
28 System.out.print((char) by);
29 }
30 bais.close();
31 }
32}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected