title: Java: File type of `url.openStream()`
body: <p>I wrote this this method to download a webpage given a URL.  It is designed to download HTML only.  If I want to do error checking and allow HTML only how should I do this?  </p>
  
  <pre><code>public static String download(URL url) throws IOException {
      InputStream is = url.openStream();
      BufferedReader reader = new BufferedReader(new InputStreamReader(is));
      String page = "";
      String line;    
      while((line = reader.readLine()) != null){
          page = page + line;
      }
      return page;
  }
  </code></pre>
  
  <p>Originally I was planning on doing this: </p>
  
  <pre><code>String file = url.getFile();
  if(file.subString(file.indexOf("."),file.length()-1).equalsIgnoreCase("HTML")){
      // do method
  </code></pre>
  
  <p>However the URL: <code>http://www.smu.com</code> returns <code>""</code> for <code>url.getFile()</code>.  Anyone have any suggestions?  </p>