title: Getting meaningful text from Java.io.Reader
body: <p>I have a program that I'm writing where I am using another company's library to download some reports from their website.  I want to parse these reports before I write them to a file, because if they match certain criteria, I want to disregard them.  </p>
  
  <p>Problem is, their method, called download() returns a java.io.Reader.  The only method available to me is</p>
  
  <pre><code>int read(char[] cbuf);
  </code></pre>
  
  <p>Printing this returned array out gives me meaningless characters.  I want to be able to identify what character set I'm working with or convert it to a byte array but I can't figure out how to do it.  I've tried</p>
  
  <pre><code>//retrievedFile is my Reader object
  char[] cbuf = new char[2048];
  int numChars = retrievedFile.read(cbuf);
  //I've tried other character sets, too
  new String(cbuf).getBytes("UTF-8");
  </code></pre>
  
  <p>and I'm afraid to downcast to a more useful reader because I can't know for sure if it will work or not.  Any suggestions?</p>
  
  <h1>EDIT</h1>
  
  <p>When I say it prints out "meaningless characters", I don't mean that it looks like the example given by Jon Skeet.  It's really hard to describe because I'm not at my machine right now, but I think it's an encoding issue.  The characters seem to have indentations and structure similar to the look of the reports.  I'll try these suggestions as soon as I get back on Tuesday (I'm only an intern, so I haven't bothered with setting up a remote account or anything).</p>