Snippets tagged “bytearrayoutputstream”
2 snippets use this tag.
- Convert InputStream to byte array in JavaJava
To convert an InputStream to a byte array in Java, you can use the readAllBytes() method of the java.nio.file.Files class from the java.nio.file package.
- Get an OutputStream into a StringJava
To get an OutputStream into a String, you can use a ByteArrayOutputStream as the OutputStream and then use the toString() method of the ByteArrayOutputStream to get the contents of the stream as a string.