Java URL Connection getBooleanFromUrl(String url)

Here you can find the source of getBooleanFromUrl(String url)

Description

get Boolean From Url

License

Open Source License

Declaration

public static boolean getBooleanFromUrl(String url) throws Exception 

Method Source Code


//package com.java2s;
/*  This file is part of WhitelistManager.
 * //ww w .j  a va  2s .  c o m
 *  WhitelistManager is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  WhitelistManager is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with WhitelistManager.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Main {
    public static boolean getBooleanFromUrl(String url) throws Exception {
        URL website = new URL(url);
        URLConnection connection = website.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        StringBuilder response = new StringBuilder();
        String inputLine;
        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();
        if (response.toString().equals("true")) {
            return true;
        } else {
            return false;
        }
    }
}

Related

  1. findClasspathUrls(ClassLoader classLoader)
  2. findResourceInJarPackage(URL url, String packageName, String packageDirName, boolean recursive, List resources)
  3. getAsStream(URL url)
  4. getBaseAuthInputStreamFromURL(String query, String basicAuthString)
  5. getBaseURL(URLConnection conn)
  6. getBytes(String urlStr)
  7. getCharset(URLConnection connection)
  8. getCharsFromURL(URL url)
  9. getChildren(URL url)