GENDER API JAVA

First install our library with composer:

See full client documentation here:

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

First install our library with npm:

See full client documentation here:

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

First install our library with npm:

See full client documentation here:

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

importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStreamReader;importjava.net.HttpURLConnection;importjava.net.URL;importcom.google.gson.Gson;importcom.google.gson.JsonObject;publicclassMain{publicstaticvoidmain(String[] args){try{String myKey ="insert your server key here";URL url =newURL("https://gender-api.com/get?key="+ myKey +"&name=markus");HttpURLConnection conn =(HttpURLConnection) url.openConnection();if(conn.getResponseCode()!=200){thrownewRuntimeException("Error: "+ conn.getResponseCode());}InputStreamReader input =newInputStreamReader(conn.getInputStream());BufferedReader reader =newBufferedReader(input);Gson gson =newGson();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();}}}
Chat
close