'Turn HttpExchange POST JSON request body to string

There are some other longer solutions I found, but I was wondering if the following works as well:

I have HttpExchange message, that is a POST request that is passed in, and write String jsonPayload = new String(message.getRequestBody().readAllBytes());. Would this turn the request body's json to a string?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source