title: How do I return a String in a try/catch statment?
body: <p>I am trying to return a String from the following method.</p>
  
  <pre><code>public String openCon() {
      try {
          Scanner scan = new Scanner(System.in);
          URL sitex = new URL("http://" + scan.nextLine());
          URLConnection connection = sitex.openConnection();
          Object content = sitex.getContent();
          BufferedReader in = new BufferedReader(new InputStreamReader(sitex.openStream()));
          String str;
          String x = "1";
          while ((str = in.readLine()) != null) {
            x += str;
          }
          in.close();
          return x;
  
     }
     catch(Exception e) {
          System.out.println(e);
     }
  }
  </code></pre>