title: how to get other than english text as response using java
body: <p>I am getting response from Wikipedia page and paste the response in html file. If I open the html file in browser I am not able to get the languages other than English as it is (I used UTF-8). I am attaching the picture of languages as in html.</p>
  
  <p><a href="https://i.stack.imgur.com/CQoks.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CQoks.png" alt="enter image description here"></a></p>
  
  <p>I tried in couple of ways to get the response using java, and they are as follows,</p>
  
  <p>Way 1,</p>
  
  <pre><code>    URL url = new URL ("https://en.wikipedia.org/wiki/Sachin_Tendulkar");
      byte[] encodedBytes = Base64.encodeBase64("root:pass".getBytes());
      //System.out.println("Host --------"+url.getHost());
      String encoding = new String (encodedBytes);
  
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      connection.setRequestMethod("GET");
      connection.setRequestProperty("Accept-Charset", "UTF-8");
      connection.setRequestProperty("Content-Type", "text/xml; charset=UTF-8");
      connection.setDoInput (true);
      connection.setRequestProperty  ("Authorization", "Basic " + encoding);
      connection.connect();
  
      InputStream content = (InputStream)connection.getInputStream();
      BufferedReader in   = new BufferedReader (new InputStreamReader (content));
      String line;
  
      while ((line = in.readLine()) != null) {
          String s = line.toString();
              System.out.println(s);
          }
  </code></pre>
  
  <p>I also tried the following code, but this also not showing the fonts as it is in 
  wiki,</p>
  
  <pre><code>            URL url;
              HttpURLConnection conn;
              BufferedReader rd;
              String line;
              StringBuilder result = new StringBuilder();
              try {
                 url = new URL("https://en.wikipedia.org/wiki/Sachin_Tendulkar");
                 conn = (HttpURLConnection) url.openConnection();
                 conn.setRequestMethod("GET");
                 conn.setRequestProperty("Accept-Charset", "UTF-8");
                 conn.setRequestProperty("Content-Type", "text/xml; charset=UTF-8");
  
                 rd = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
                 while ((line = rd.readLine()) != null) {
                    byte [] b = line.getBytes("UTF-8");
                    result.append(line);
                    System.out.println(result.append(line));
                 }
                 rd.close();
              } catch (Exception e) {
                 e.printStackTrace();
              }
  </code></pre>