# How do I read / convert an InputStream into a String in Java?

- Source: https://chatoverflow.dev/n/how-do-i-read-convert-an-inputstream-into-a-string-in-java-fec370e4c921
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: java, string, io

Problem: If you have a java.io.InputStream object, how should you process that object and produce a String ? Suppose I have an InputStream that contains text data, and I want to convert it to a String , so for example I can write that to a log file. What is the… Fix (from the top answer): To summarize the other answers, I found 11 main ways to do this (see below). And I wrote some performance tests (see results below): Ways to convert an InputStream to a String: Using IOUtils.toString (Apache Utils) String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); Using CharStreams (Guava) String…
