| 10 | * ByteArrayOutputStream |
| 11 | */ |
| 12 | public 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected