Domain availability Java program

Domain availability Java program

Register in the for api key, of course its free.
Once you got the apikey replace in the below program and run.

Requied Jar file:
Java Json Jar

Domain Availability Java program:


import org.json.JSONException;
import org.json.JSONObject;

public class DomainCheck {

	public static void main(String[] args) {
		DomainCheck dc = new DomainCheck();
		String apikey = "XXXXXXXXXX";
		String isEnteredDomainAvailable = dc.getDomainAvailable("",apikey);


	private String getDomainAvailable(String domainName,String apiKey) {
		String domainAvailabilityStatus = null;

		try {
			URL url = new URL(
			URLConnection connection = url.openConnection();
			String line;
			StringBuilder builder = new StringBuilder();
			BufferedReader reader = new BufferedReader(new InputStreamReader(
			while ((line = reader.readLine()) != null) {

			try {
				JSONObject json = new JSONObject(builder.toString());
				String isDomainValid = (String) json.get("status");
				if (isDomainValid.equalsIgnoreCase("success")) {
					boolean isDomainAvailableJson = (boolean) json.get("available");
						domainAvailabilityStatus = "congratz, Domain Available for you!";
						domainAvailabilityStatus = "Someone using the Domain already";
				} else {
					domainAvailabilityStatus = "API key wrong (or) Invalid Domain Name" ;

			} catch (JSONException e) {
				domainAvailabilityStatus = "Server May Be Busy or Server May Be Down";
		} catch (IOException e) {
			domainAvailabilityStatus = "Server May Be Busy or Server May Be Down";
		return domainAvailabilityStatus;

Output (once apikey changed):
congratz, Domain Available for you!

Revert me back if you need further assistance.

699 total views, 3 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.