String exampleString = "example";
If I have a code like this, how do I put it in InputStream??
InputStream stream = new ByteArrayInputStream(exampleString.getBytes(StandardCharsets.UTF_8));
You can do it in this way. StandardCharsets.The UTF_8
part assumes encoding as UTF-8, but you can change it according to encoding. And from java 6, Standard charsets.Change UTF_8
to "UTF-8"
.
© 2024 OneMinuteCode. All rights reserved.