Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;

import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    static String url = "http://api.godex.io:8080/api/";
    static String charset = "UTF-8";
    static int statusCode = 200;

    public static boolean deleteRequest(String query) {
        HttpURLConnection connection = null;
        try {
            connection = (HttpURLConnection) new URL(url + query).openConnection();
            connection.setRequestMethod("DELETE");
            connection.setRequestProperty("Accept-Charset", charset);

            statusCode = connection.getResponseCode();
            if (statusCode != 200) {
                return false;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return true;
    }
}