Loading
Java InputStream To String

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  convert InputStream To String


Ans)

File InputStream to String

This method converts InputStream to String using Java.

  InputStream inputStream = getClass().getResourceAsStream("/test.xml");

  public static String convertInputStreamToString(InputStream inputStream) {  
   StringBuffer strBuffer = new StringBuffer();  
   if (inputStream != null){
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
    String line = null;
    try {
     while ((line = reader.readLine()) != null) {
      strBuffer.append(line + "\n");
     }
    } catch (IOException e) {
     e.printStackTrace();
    } finally {
     try {
      inputStream.close();
     } catch (IOException e) {
      e.printStackTrace();
     }
    }
   }
   return strBuffer.toString();
  }



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Java InputStream To String


Java InputStream To String

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free