title: Getting "401" response code when trying to connect local server?
body: <p>I've a local server which runs on <strong><a href="http://192.168.0.101:8080/" rel="nofollow noreferrer">http://192.168.0.101:8080/</a></strong>. Whenver I try to ping the server using following code I get response code as "401". My server requires password as "12345"</p>
  
  <pre><code>try {
      URL url = new URL("http://192.168.0.101:8080/");  
      HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
      urlc.setRequestMethod("GET");
      urlc.setConnectTimeout(10 * 1000);          // 10 s.
      urlc.connect();
  
      System.out.println("code" + urlc.getResponseCode());
      if (urlc.getResponseCode() == 200) {        // 200 = "OK" code (http connection is fine).
           System.out.println("Connection success");
  
      } else {
          System.out.println("Connection nada");
      }
  } catch (MalformedURLException e1) {
      System.out.println("MalformedURLException");
  } catch (IOException e) {
      System.out.println("IOException nada");
  }
  </code></pre>