How to convert inputstream to string in java / Various ways of converting inputstream to string in java
java.io.InputStream represents a stream of bytes. Often when reading binary files or from a network, data is returned in an input stream format and we need to read that data and convert it to a string format so that it becomes meaningful. This post will list out various methods in which the content of an input stream can be converted to a java.lang.String. All the methods assume that you have a source input stream available. Method 1: Using Scanner class java.io.Scanner class has a constructor which takes a java.io.Inputstream as argument. Once an object of scanner is created, use its hasNext and next methods toRead More →