Welcome to the World of Online Learning:
Hello Friends “This blog helps you to learn Java programming concepts. You can learn Java language at your own speed and time. One can learn concepts of Java language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Write a Java Program to Convert InputStream to String
PROGRAM: Java Program to Convert InputStream to String
/*Java Program to Convert InputStream to String*/
import java.io.*;
public class InputStreamString {
public static void main(String[] args) throws IOException {
InputStream stream = new ByteArrayInputStream(“Hello there!”.getBytes());
StringBuilder sb = new StringBuilder();
String line;
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
while ((line = br.readLine()) != null) {
sb.append(line);
}
br.close();
System.out.println(sb);
}
}