title: How to check given domain name http or https in java?
body: <p><strong>My problem</strong></p>
  
  <p>In my android application I get url input from user, like "www.google.com".</p>
  
  <p>I want to find out for the given url whether to use <code>http</code> or <code>https</code>.</p>
  
  <p><strong>What I have tried</strong></p>
  
  <p>after referring to some Stack Overflow questions I tried with <strong>getScheme()</strong></p>
  
  <pre><code>try {
      String url_name="www.google.com";
      URI MyUri = new URI(url_name);
      String http_or_https="";
      http_or_https=MyUri.getScheme();
      url_name=http_or_https+"://"+urlname;
      Log.d("URLNAME",url_name);
  }
  catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>But my above code throws an exception.</p>
  
  <p><strong>My question</strong></p>
  
  <p><strong>Is above approach getScheme() correct or not?</strong></p>
  
  <p>If above approach is incorrect, how to find url http or https?</p>