{"id":1503,"date":"2017-03-21T18:04:24","date_gmt":"2017-03-21T12:34:24","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=1503"},"modified":"2017-03-29T10:38:33","modified_gmt":"2017-03-29T05:08:33","slug":"java-readconvert-inputstream-string","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/java-readconvert-inputstream-string\/","title":{"rendered":"JAVA &#8211; Read\/convert an InputStream to a String"},"content":{"rendered":"<ul>\n<li>The <b>Java.io.InputStream<\/b> class is the superclass of all classes representing an input stream of bytes.<\/li>\n<li>Applications that need to define a subclass of InputStream must always provide a method that returns the next byte of input<\/li>\n<\/ul>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-1506 size-full\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2017\/03\/Pictu.png\" alt=\"\" width=\"717\" height=\"386\" \/><\/p>\n<p>\u00a0<\/p>\n<ul>\n<li>It explains concept of how to read and write date e.g. bytes from input source like file, network, keyboard and writing data to console, file, network and program.<\/li>\n<li>InputStream is used to read data and OutputStream is used to write data.<\/li>\n<li>Data can be on any format (e.g. Text or Binary). We can even read data in particular type by using DataInputStream.<\/li>\n<li>Java provides char, int, float, double, long and other data types to store data read in that way.<\/li>\n<li>Character streams (e.g. Readers) are used to read character data while Byte Streams (e.g. InputStream) are used to read binary data.<\/li>\n<\/ul>\n<h4 id=\"example-read-and-convert-an-inputstream-to-a-string\"><span style=\"color: #808000;\"><b>Example:<\/b> <b>Read and Convert an InputStream to a String<\/b><\/span><\/h4>\n<p>Here is the complete example of how to read and convert an InputStream to a String.<\/p>\n<p>The steps involved are:<\/p>\n<ul>\n<li>We have initialized the Input Stream after converting the file content to bytes using get Bytes() method and then using the Byte Array Input Stream which contains an internal buffer that contains bytes that may be read from the stream.<\/li>\n<li>Read the Input Stream using Input Stream Reader.<\/li>\n<li>Read Input Stream Reader using Buffered Reader.<\/li>\n<li>Appended each line to a String Builder object which has been read by Buffered Reader.<\/li>\n<li>Finally converted the String Builder to String using to String() method.<\/li>\n<\/ul>\n[pastacode lang=\u201djava\u201d manual=\u201dimport%20java.io.BufferedReader%3B%0Aimport%20java.io.ByteArrayInputStream%3B%0Aimport%20java.io.IOException%3B%0Aimport%20java.io.InputStream%3B%0Aimport%20java.io.InputStreamReader%3B%0A\u201d message=\u201djava code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[pastacode lang=\u201djava\u201d manual=\u201dpublic%20class%20WikitechyExample%20%0A%7B%0A%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20throws%20IOException%20%0A%7B%0A%20%20%20%20%20%20%20InputStreamReader%20isr%20%3D%20null%3B%0A%20%20%20%20%20%20%20BufferedReader%20br%20%3D%20null%3B%0A%20%20%20%20%20%20%20InputStream%20is%20%3D%20new%20ByteArrayInputStream(%22Welcome%20to%20wikitechy%22.getBytes())%3B%0AStringBuilder%20sb%20%3D%20new%20StringBuilder()%3B%0A%20%20%20%20%20%20%20String%20content%3B%0A%20try%20%0A%7B%0A%20%20%20%20%20%20%20%20%20%20%20isr%20%3D%20new%20InputStreamReader(is)%3B%0A%09%20%20%20br%20%3D%20new%20BufferedReader(isr)%3B%0A%09%20%20%20while%20((content%20%3D%20br.readLine())%20!%3D%20null)%20%0A%7B%0A%09%09sb.append(content)%3B%0A%7D%0A%7D%20catch%20(IOException%20ioe)%20%0A%7B%0A%09%09System.out.println(%22IO%20Exception%20occurred%22)%3B%0A%09%09ioe.printStackTrace()%3B%09%0A%20%7D%20finally%20%0A%7B%0A%09%09isr.close()%3B%0A%09%09br.close()%3B%0A%7D%0A%20%20%20%20%20%20%20%20String%20mystring%20%3D%20sb.toString()%3B%0A%09System.out.println(mystring)%3B%0A%20%7D%0A%7D%0A\u201d message=\u201djava code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\n<h4 id=\"output\"><strong><span style=\"color: #ff6600;\">Output:<\/span><\/strong><\/h4>\n<p><strong>Welcome to wikitechy<\/strong><\/p>\n<h4 id=\"3-ways-to-read-files-in-java-nio\"><span style=\"color: #800080;\"><b>3 Ways to Read files in java NIO:<\/b><\/span><\/h4>\n<ul>\n<li>If we are using java.nio package for reading a file, we can read some effective ways to read files in java NIO.<\/li>\n<\/ul>\n<p>\u00a0<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-1510 size-full\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2017\/03\/Pic-1.png\" alt=\"\" width=\"575\" height=\"191\" \/><\/p>\n<ul>\n<li>Using BufferedReader<\/li>\n<li>Using apache commons IOUtils<\/li>\n<li>Using java.util.Scanner<\/li>\n<\/ul>\n<h4 id=\"using-bufferedreader\"><span style=\"color: #ff6600;\"><b>U<\/b><b>sing <\/b><b>BufferedReader<\/b><\/span><\/h4>\n[pastacode lang=\u201djava\u201d manual=\u201dpackage%20com.howtodoinjava.demo.io%3B%0A%20import%20java.io.BufferedReader%3B%0Aimport%20java.io.File%3B%0Aimport%20java.io.FileInputStream%3B%0Aimport%20java.io.FileNotFoundException%3B%0Aimport%20java.io.IOException%3B%0Aimport%20java.io.InputStream%3B%0Aimport%20java.io.InputStreamReader%3B%0A%20public%20class%20ReadStreamIntoStringUsingReader%7B%0A%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20throws%20FileNotFoundException%2C%20IOException%20%20%7B%0A%20%20%20%20%20%20%20%20InputStream%20wikiin%20%3D%20new%20FileInputStream(new%20File(%22C%3A%2Ftemp%2Ftest.txt%22))%3B%0A%20%20%20%20%20%20%20%20BufferedReader%20reader%20%3D%20new%20BufferedReader(new%20InputStreamReader(wikiin))%3B%0A%20%20%20%20%20%20%20%20StringBuilder%20out%20%3D%20new%20StringBuilder()%3B%0A%20%20%20%20%20%20%20%20String%20line%3B%0A%20%20%20%20%20%20%20%20while%20((line%20%3D%20reader.readLine())%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20out.append(line)%3B%0A%7D%0A%20%20%20%20%20%20%20%20System.out.println(out.toString())%3B%20%20%20%2F%2FPrints%20the%20string%20content%20read%20from%20input%20stream%0A%20%20%20%20%20%20%20%20reader.close()%3B%0A%7D%0A%7D%0A\u201d message=\u201djava code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<h4 id=\"using-apache-commons-ioutils\"><span style=\"color: #808000;\"><b>Using apache commons IOUtils<\/b><\/span><\/h4>\n<ul>\n<li>Apache commons has a very classy facility for this purpose which makes code is easy to read.<\/li>\n<\/ul>\n[pastacode lang=\u201djava\u201d manual=\u201dpackage%20com.howtodoinjava.demo.io%3B%0Aimport%20java.io.File%3B%0Aimport%20java.io.FileInputStream%3B%0Aimport%20java.io.FileNotFoundException%3B%0Aimport%20java.io.IOException%3B%0Aimport%20java.io.StringWriter%3B%0Aimport%20org.apache.commons.io.IOUtils%3B%0A%20public%20class%20ReadStreamIntoStringUsingIOUtils%0A%7B%0A%20public%20static%20void%20main(String%5B%5D%20args)%20throws%20FileNotFoundException%2C%20IOException%20%7B%0A%20%20%20%20%20%20%20%20%2F%2FMethod%201%20IOUtils.copy()%0A%20%20%20%20%20%20%20%20StringWriter%20writer%20%3D%20new%20StringWriter()%3B%0A%20%20%20%20%20%20%20%20IOUtils.copy(new%20FileInputStream(new%20File(%22C%3A%2Ftemp%2Ftest.txt%22))%2C%20writer%2C%20%22UTF-8%22)%3B%0A%20%20%20%20%20%20%20%20String%20theString%20%3D%20writer.toString()%3B%0A%20%20%20%20%20%20%20%20System.out.println(theString)%3B%0A%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%2F%2FMethod%202%20IOUtils.toString()%0A%20%20%20%20%20%20%20%20String%20theString2%20%3D%20IOUtils.toString(new%20FileInputStream(new%20File(%22C%3A%2Ftemp%2Ftest.txt%22))%2C%20%22UTF-8%22)%3B%0A%20%20%20%20%20%20%20%20System.out.println(theString2)%3B%0A%20%20%20%20%7D%7D%0A\u201d message=\u201djava code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\n<h4 id=\"using-java-util-scanner\"><span style=\"color: #ff6600;\"><b>Using <\/b><b>java.util.Scanner<\/b><\/span><\/h4>\n<ul>\n<li>The reason it works is because Scanner iterates over tokens in the stream, and in this case we separate tokens using \u201cbeginning of the input boundary\u201d (A) thus giving us only one token for the entire contents of the stream.<\/li>\n<\/ul>\n[pastacode lang=\u201djava\u201d manual=\u201dpackage%20com.howtodoinjava.demo.io%3B%0Aimport%20java.io.File%3B%0Aimport%20java.io.FileInputStream%3B%0Aimport%20java.io.FileNotFoundException%3B%0Aimport%20java.io.IOException%3B%0Apublic%20class%20ReadStreamIntoStringUsingScanner%0A%7B%0A%20%20%20%20%40SuppressWarnings(%22resource%22)%0A%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20throws%20FileNotFoundException%2C%20IOException%20%0A%7B%0A%20%20%20%20%20%20%20%20FileInputStream%20fin%20%3D%20new%20FileInputStream(new%20File(%22C%3A%2Ftemp%2Ftest.txt%22))%3B%0A%20%20%20%20%20%20%20%20java.util.Scanner%20scanner%20%3D%20new%20java.util.Scanner(fin%2C%22UTF-8%22).useDelimiter(%22%5CA%22)%3B%0A%20%20%20%20%20%20%20%20String%20theString%20%3D%20scanner.hasNext()%20%3F%20scanner.next()%20%3A%20%22%22%3B%0A%20%20%20%20%20%20%20%20System.out.println(theString)%3B%0A%20%20%20%20%20%20%20%20scanner.close()%3B%0A%7D%0A%7D%0A\u201d message=\u201djava code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<h4 id=\"read-inputstream-as-string-in-java-jdk7-guava-and-apache-commons\"><span style=\"color: #808000;\"><b>Read InputStream as String in Java \u2013 JDK7, Guava and Apache Commons<\/b><\/span><\/h4>\n<ul>\n<li>Inside Java program, we often use String object to store and pass file data, that\u2019s why we need a way to convert InputStream to String in Java.<\/li>\n<li>For example In Java, we read data from file or socket using InputStream and write data using OutputStream.<\/li>\n<li>Java programming language provides streams to read data from a file, a socket and from other sources e.g. byte array, but developers often find themselves with several issues e.g. how to open connection to read data, how to close connection after reading or writing into file, how to handle IOException (e.g. FileNotFoundException, EOFFileException etc).<\/li>\n<\/ul>\n<h4 id=\"3-example-to-read-inputstream-as-string-in-java\"><span style=\"color: #800080;\"><b>3 Example to Read InputStream as String in java:<\/b><\/span><\/h4>\n<ul>\n<li><b>Using Core Java classes<\/b><\/li>\n<li><b>Using Apache Commons IO<\/b><\/li>\n<li><b>Using Google Guava library<\/b><\/li>\n<\/ul>\n<h4 id=\"using-core-java-classes\"><span style=\"color: #ff6600;\"><b>Using Core Java classes<\/b><\/span><\/h4>\n<ul>\n<li>This approach is best suited to application running on Java 7, as we are using try-with-resource statements to automatically close input streams, but we can just take out that piece and can close streams in finally block, if we are running on Java 6 or lower version.<\/li>\n<li>Here is the steps and\u00a0 code sample of reading InputStream as String in Java :<\/li>\n<\/ul>\n<p>Step 1: Open FileInputStream to read contents of File as InputStream.<\/p>\n<p>Step 2: Create InputStreamReader with character encoding to read byte as characters<\/p>\n<p>Step 3: Create BufferedReader to read file data line by line<\/p>\n<p>Step 4: Use StringBuilder to combine lines<\/p>\n[pastacode lang=\u201djava\u201d manual=\u201dtry%C2%A0(InputStream%C2%A0in%C2%A0%3D%C2%A0new%C2%A0FileInputStream(%22wikitechy.txt%22)%3B%0A%C2%A0BufferedReader%C2%A0r%C2%A0%3D%C2%A0new%C2%A0BufferedReader(new%C2%A0InputStreamReader(in%2C%C2%A0StandardCharsets.UTF_8)))%0A%20%7B%C2%A0%0AString%C2%A0str%C2%A0%3D%C2%A0null%3B%C2%A0%0AStringBuilder%C2%A0sb%C2%A0%3D%C2%A0new%C2%A0StringBuilder(8192)%3B%C2%A0%0Awhile%C2%A0((str%C2%A0%3D%C2%A0r.readLine())%C2%A0!%3D%C2%A0null)%20%0A%7B%0A%20sb.append(str)%3B%20%0A%7D%C2%A0%0ASystem.out.println(%22data%20from%20InputStream%20as%20String%20%3A%20%22%C2%A0%2B%C2%A0sb.toString())%3B%20%0A%7D%0A%C2%A0catch%C2%A0(IOException%C2%A0ioe)%20%0A%7B%20%0Aioe.printStackTrace()%3B%20%0A%7D\u201d message=\u201djava code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<ul>\n<li>Closing of InputStream is taken care by Java itself because they are declared as try-with-resource statement.<\/li>\n<li>Our File contains a single line, which contains some French characters, to demonstrate use of character encoding.<\/li>\n<li>We have provided UTF-8 to InputStreamReader just for this purpose.<\/li>\n<\/ul>\n<h4 id=\"using-apache-commons-io\"><span style=\"color: #808000;\"><b>Using Apache Commons IO<\/b><\/span><\/h4>\n<ul>\n<li>In this example, we are using IOUtils class from Apache commons IO to read InputStream data as String.<\/li>\n<li>It provides a toString() method to convert InputStream to String.<\/li>\n<li>This is the most easiest way to get String from stream, but we should also don\u2019t rely on them to close our streams.<\/li>\n<li>If we are using automatic resource management feature of Java 7, which closes any resource opened in try() statement.<\/li>\n<\/ul>\n[pastacode lang=\u201djava\u201d manual=\u201dtry%C2%A0(FileInputStream%C2%A0fis%C2%A0%3D%C2%A0new%C2%A0FileInputStream(%22wikitechy.txt%22)%3B)%20%0A%7B%C2%A0%0AString%C2%A0text%C2%A0%3D%C2%A0IOUtils.toString(fis%2C%C2%A0StandardCharsets.UTF_8.name())%3B%C2%A0%0ASystem.out.println(%22String%20generated%20by%20reading%20InputStream%20in%20Java%20%3A%20%22%C2%A0%2B%C2%A0text)%3B%20%0A%7D%C2%A0%0Acatch%C2%A0(IOException%C2%A0io)%20%0A%7B%20%0Aio.printStackTrace()%3B%0A%20%7D\u201d message=\u201djava code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\n<h4 id=\"using-google-guava-library\"><span style=\"color: #800080;\"><b>Using Google Guava library<\/b><\/span><\/h4>\n<ul>\n<li>In this example, we have used Google Guava library to read contents of InputStream as String.<\/li>\n<li>Here input stream is not obtained from file instead from a byte array, which is generated by converting an String to byte array.<\/li>\n<li>It always better to provide encoding while calling getBytes() method of String, so that data is converted correctly.<\/li>\n<li>In example, we have provided \u201cUTF-8\u201d, though we can also use StandardCharsets.UTF_8.name().<\/li>\n<li>CharStreams.toString() doesn\u2019t close Stream from which it is reading characters, that\u2019s why we have opened stream in try (\u2026) parenthesis, so that it will be automatically closed by Java.<\/li>\n<\/ul>\n[pastacode lang=\u201djava\u201d manual=\u201dString%C2%A0stringWithSpecialChar%C2%A0%3D%C2%A0%22Soci%C3%A9t%C3%A9%20G%C3%A9n%C3%A9rale%22%3B%0A%C2%A0try%C2%A0(final%C2%A0InputStream%C2%A0in%C2%A0%3D%C2%A0new%C2%A0ByteArrayInputStream(stringWithSpecialChar.getBytes(%22UTF-8%22))%3B%0A%C2%A0final%C2%A0InputStreamReader%C2%A0inr%C2%A0%3D%C2%A0new%C2%A0InputStreamReader(in))%20%0A%7B%0A%C2%A0String%C2%A0text%C2%A0%3D%C2%A0CharStreams.toString(inr)%3B%C2%A0System.out.println(%22String%20from%20InputStream%20in%20Java%3A%20%22%C2%A0%2B%C2%A0text)%3B%20%0A%7D%C2%A0%0Acatch%C2%A0(IOException%C2%A0e)%0A%20%7B%0A%20e.printStackTrace()%3B%0A%20%7D\u201d message=\u201djava code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<h4 id=\"complete-java-program-of-inputstream-to-string-in-java\"><span style=\"color: #ff6600;\"><b>Complete java program of inputstream to string in java<\/b><\/span><\/h4>\n<ul>\n<li>Here is the full code listing of 3 ways to read InputStream as String in Java Program.<\/li>\n<li>In order to run this program, copy this code into a file and save it as InputStreamToString.java, after this compile this file using javac command, if javac is not in our included in our PATH environment variable, then we can directly run it from bin folder of our JDK installation directory, also known as JAVA_HOME.<\/li>\n<li>After compilation, we can run our program by using java command e.g. java -classpath . InputStreamToString .<\/li>\n<\/ul>\n<p>It shows examples from core Java, Google Guava and Apache commons library.<\/p>\n[pastacode lang=\u201djava\u201d manual=\u201dimport%C2%A0java.io.BufferedReader%3B%C2%A0%0Aimport%C2%A0java.io.ByteArrayInputStream%3B%C2%A0%0Aimport%C2%A0java.io.FileInputStream%3B%C2%A0%0Aimport%C2%A0java.io.FileNotFoundException%3B%C2%A0%0Aimport%C2%A0java.io.IOException%3B%0A%C2%A0import%C2%A0java.io.InputStream%3B%C2%A0%0Aimport%C2%A0java.io.InputStreamReader%3B%C2%A0%0Aimport%C2%A0java.nio.charset.StandardCharsets%3B%0A%C2%A0import%C2%A0org.apache.commons.io.Charsets%3B%C2%A0%0Aimport%C2%A0org.apache.commons.io.IOUtils%3B%0A%C2%A0importcom.google.common.io.CharStreams%3B%0A%C2%A0import%C2%A0com.google.common.io.InputSupplier%0Apublic%C2%A0class%C2%A0InputStreamToString%C2%A0%7B%C2%A0public%C2%A0static%C2%A0void%C2%A0main(String%C2%A0args%5B%5D)%0A%20%7B%0A%C2%A0%2F%2F%20InputStream%20to%20String%20-%20Core%20Java%20Example%C2%A0%0Atry%C2%A0(InputStream%C2%A0in%C2%A0%3D%C2%A0new%C2%A0FileInputStream(%22wikitechy.txt%22)%3B%C2%A0%0ABufferedReader%C2%A0r%C2%A0%3D%C2%A0new%C2%A0BufferedReader(new%C2%A0InputStreamReader(in%2C%C2%A0StandardCharsets.UTF_8)))%20%0A%7B%C2%A0%0AString%C2%A0str%C2%A0%3D%C2%A0null%3B%C2%A0%0AStringBuilder%C2%A0sb%C2%A0%3D%C2%A0new%C2%A0StringBuilder(8192)%3B%C2%A0%0Awhile%C2%A0((str%C2%A0%3D%C2%A0r.readLine())%C2%A0!%3D%C2%A0null)%20%0A%7B%20%0Asb.append(str)%3B%20%0A%7D%C2%A0%0ASystem.out.println(%22data%20from%20InputStream%20as%20String%20%3A%20%22%C2%A0%2B%C2%A0sb.toString())%3B%20%0A%7D%C2%A0%0Acatch%C2%A0(IOException%C2%A0ioe)%20%0A%7B%20%0Aioe.printStackTrace()%3B%0A%7D\u201d message=\u201djava code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[pastacode lang=\u201djava\u201d manual=\u201d%2F%2F%20Converting%20InputStream%20to%20String%20in%20Java%20-%20Google%20Guava%20Example%C2%A0%0AString%C2%A0stringWithSpecialChar%C2%A0%3D%C2%A0%22Soci%C3%A9t%C3%A9G%C3%A9n%C3%A9rale%22%3B%C2%A0%0Atry%C2%A0(final%C2%A0InputStream%C2%A0in%C2%A0%3D%C2%A0new%C2%A0ByteArrayInputStream(stringWithSpecialChar.getBytes(%22UTF-8%22))%3B%C2%A0%0Afinal%C2%A0InputStreamReader%C2%A0inr%C2%A0%3D%C2%A0new%C2%A0InputStreamReader(in))%20%0A%7B%C2%A0%0AString%C2%A0text%C2%A0%3D%C2%A0CharStreams.toString(inr)%3B%C2%A0%0ASystem.out.println(%22String%20from%20InputStream%20in%20Java%3A%20%22%C2%A0%2Btext)%3B%0A%20%7D%C2%A0%0Acatch%C2%A0(IOException%C2%A0e)%20%7B%20e.printStackTrace()%3B%20%0A%7D%C2%A0\u2033 message=\u201djava code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[pastacode lang=\u201djava\u201d manual=\u201d%2F%2F%20Reading%20data%20from%20InputStream%20as%20String%20in%20Java%20-%20Apache%20Commons%20Example%C2%A0%0Atry%C2%A0(FileInputStream%C2%A0fis%C2%A0%3D%C2%A0new%C2%A0FileInputStream(%22wikitechy.txt%22)%3B)%0A%20%7B%C2%A0%0AString%C2%A0text%C2%A0%3D%C2%A0IOUtils.toString(fis%2C%C2%A0StandardCharsets.UTF_8.name())%3B%C2%A0%0ASystem.out.println(%22String%20generated%20by%20reading%20InputStream%20in%20Java%20%3A%20%22%C2%A0%2B%C2%A0text)%3B%0A%20%7D%C2%A0%0Acatch%C2%A0(IOException%C2%A0io)%20%0A%7B%20%0Aio.printStackTrace()%3B%20%0A%7D%20%0A%7D%0A%20%7D\u201d message=\u201djava code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<h4 id=\"output-2\"><span style=\"color: #808000;\"><b>Output:\u00a0<\/b><\/span><\/h4>\n<p><strong>data from\u00a0InputStream\u00a0as\u00a0String\u00a0:\u00a0Soci\u00e9t\u00e9\u00a0G\u00e9n\u00e9rale\u00a0is a\u00a0French\u00a0bank\u00a0Headquarters\u00a0at \u00cele-de-France,\u00a0France\u00a0<\/strong><\/p>\n<p><strong>String\u00a0from\u00a0InputStream\u00a0in\u00a0Java:\u00a0Soci\u00e9t\u00e9\u00a0G\u00e9n\u00e9rale\u00a0<\/strong><\/p>\n<p><strong>String\u00a0generated by reading\u00a0InputStream\u00a0in\u00a0Java\u00a0:\u00a0Soci\u00e9t\u00e9\u00a0G\u00e9n\u00e9rale\u00a0is a\u00a0French\u00a0bank\u00a0Headquarters\u00a0at \u00cele-de-France, France<\/strong><\/p>\n[ad type=\u201dbanner\u201d]<b><br \/>\n<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Java.io.InputStream class is the superclass of all classes representing an input stream of bytes. Applications that need to define a subclass of InputStream must always provide a method that returns the next byte of input \u00a0 It explains concept of how to read and write date e.g. bytes from input source like file, network, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2139],"tags":[3065,3063,3054,3067,3069,3062,3057,2172,3064,3068,1128,3066,3056,3055,3061,3060,3058,3059],"class_list":["post-1503","post","type-post","status-publish","format-standard","hentry","category-java","tag-convert-inputstream-to-bufferedreader","tag-convert-inputstream-to-byte-array-in-java","tag-convert-inputstream-to-string-in-java","tag-converting-inputstream-from-a-zipfile-to-string","tag-converting-string-path-to-inputstream","tag-get-an-outputstream-into-a-string","tag-guava-inputstream-to-string","tag-how-do-i-convert-a-string-to-an-inputstream-in-java","tag-how-do-i-convert-an-inputstream-to-a-string-in-java","tag-how-to-chain-multiple-different-inputstreams-into-one-inputstream","tag-how-to-check-whether-a-string-contains-a-substring-in-javascript","tag-how-to-convert-a-string-to-an-int-in-java","tag-inputstream-to-string-android","tag-inputstream-to-string-java-8","tag-java-8-stream-to-string","tag-java-read-inputstream-line-by-line","tag-java-read-inputstream-to-byte-array","tag-scala-inputstream-to-string"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/1503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=1503"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/1503\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=1503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=1503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=1503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}