Can you convert the String object of Java into InputStream and save it?

Asked 2 years ago, Updated 2 years ago, 69 views

String exampleString = "example"; If I have a code like this, how do I put it in InputStream??

java string type-conversion inputstream

2022-09-21 17:29

1 Answers

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".


2022-09-21 17:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.