code: public static String readTextStream(Reader reader) throws IOException
      {
          char[] buffer=new char[5000];
          Writer stringWriter=new StringWriter();
          int read=-1;
          try
          {
              do
              {
                  //read next buffer
                  read=reader.read(buffer);
                  
                  if(read!=-1)
                  {
                      //write to string writer
                      stringWriter.write(buffer,0,read);
                  }
              }while(read!=-1);
          }
          finally
          {
              //close streams
              IOHelper.closeResource(reader);
          }
          
          //get text
          String text=stringWriter.toString();
          
          return text;
      }
docs: Reads the text from the stream.
  
  @param   reader
  The reader to the text
  @return  The text read from the provided stream
  @throws  IOException
  Any IO exception