title: How to replicate curl command using java?
body: <p>Precisely said I want to perform below <code>curl</code> action which returns json with java:</p>
  
  <pre><code>curl -H 'Client-ID: ahh_got_ya' -X GET 'https://api.twitch.tv/helix/streams'
  </code></pre>
  
  <p>This works just fine in linux shell.</p>
  
  <p>below is my script trying to do above curl using java json:</p>
  
  <pre><code>{String urly = "https://api.twitch.tv/helix/streams";
      URL obj = new URL(urly);
      HttpURLConnection con = (HttpURLConnection) obj.openConnection();
  
      con.setRequestMethod("GET");
      con.setRequestProperty("Content-Type","application/json");
      con.setRequestProperty("Client-ID","Ahh_got_ya");
  
  
      con.setDoOutput(true);
      DataOutputStream wr = new DataOutputStream(con.getOutputStream());
      wr.writeBytes("");
      wr.flush();
      wr.close();
  
      int responseCode = con.getResponseCode();
      System.out.println("Response Code : " + responseCode);
  
      BufferedReader iny = new BufferedReader(
      new InputStreamReader(con.getInputStream()));
        String output;
        StringBuffer jsonres = new StringBuffer();
  
        while ((output = iny.readLine()) != null) {
            jsonres.append(output);
        }
      iny.close();
  
      //printing result from response
      System.out.println(response.toString());
  }
  </code></pre>
  
  <p>I am getting: <code>java.io.FileNotFoundException: https://api.twitch.tv/helix/streams</code> <code>Response Code : 404</code></p>
  
  <p>All replies are much appreciated.</p>