GENDER API JAVA

पहले कंपोजर के साथ हमारी लाइब्रेरी को इंस्टॉल करें:

यहां पूरे क्लाइंट दस्तावेज़ देखें

https://github.com/markus-perl/gender-api-client

पहले npm के साथ हमारी लाइब्रेरी इंस्टॉल करें:

यहां पूरे क्लाइंट दस्तावेज़ देखें

https://github.com/markus-perl/gender-api-client-npm

पहले npm के साथ हमारी लाइब्रेरी इंस्टॉल करें:

यहां पूरे क्लाइंट दस्तावेज़ देखें

https://github.com/markus-perl/gender-api-client-npm

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import com.google.gson.Gson;
import com.google.gson.JsonObject;

public class Main {

  public static void main(String[] args) {

  try {

    String myKey = "insert your server key here";
    URL url = new URL("https://gender-api.com/get?key=" + myKey + "&name=markus");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();

    if (conn.getResponseCode() != 200) {
      throw new RuntimeException("Error: " + conn.getResponseCode());
    }

    InputStreamReader input = new InputStreamReader(conn.getInputStream());
    BufferedReader reader = new BufferedReader(input);

    Gson gson = new Gson();
    JsonObject json = gson.fromJson(reader, JsonObject.class);
    String gender = json.get("gender").getAsString();
    System.out.println("Gender: " + gender); // Gender: male
    conn.disconnect();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}

यहां से एक नमूना प्रोजेक्ट डाउनलोड करें:

दस्तावेज़ीकरण:

https://github.com/microknights/Gender-API
चैट
हमें आपकी सहमति चाहिए
हम हमारी वेबसाइट के आगंतुकों के उपयोग के बारे में जानकारी एकत्रित करने के लिए कुकीज़ (तीसरे पक्ष की कुकीज़ सहित) का उपयोग करते हैं। ये कुकीज़ आपको सबसे अच्छा ऑनलाइन अनुभव प्रदान करने में मदद करती हैं और हमारी वेबसाइट को लगातार सुधारने में मदद करती हैं। कुकीज़ के माध्यम से एकत्रित जानकारी का उपयोग यूरोपिय संघ के बाहर भी किया जा सकता है, जैसे कि संयुक्त राज्य अमेरिका में। "सभी स्वीकार करें" बटन पर क्लिक करके, आप कुकीज़ का उपयोग करने से सहमत होते हैं। अपनी सहमति वापस लेने के लिए, कुकीज़ के उपयोग के बारे में अधिक जानकारी के लिए नीचे “हीरे” या पृष्ठ के अंत में "कुकी सेटिंग" पर क्लिक करें।