Example usage for java.net MalformedURLException printStackTrace

List of usage examples for java.net MalformedURLException printStackTrace

Introduction

In this page you can find the example usage for java.net MalformedURLException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.fxforbiz.softphone.core.managers.UpdateManager.java

/**
 * This method allow to download a file identified by the URL given in parameters, and record it in a file in the file path given in parameters.
 * @param URL The URL of the file to download.
 * @param pathOfFile The path to record the file downloaded.
 * @return Either the file is downloaded successfully or not.
 *///ww w  .j ava 2s  . co m
private boolean downloadFile(String URL, String pathOfFile) {

    try {
        URL url = new URL(URL);
        File destination = new File(pathOfFile);
        FileUtils.copyURLToFile(url, destination);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    File verifFile = new File(pathOfFile);
    return verifFile.exists();
}

From source file:net.bashtech.geobot.BotManager.java

public static String postRemoteDataStrawpoll(String urlString) {

    String line = "";
    try {/*from  w  w  w .ja  v  a  2s .c  om*/
        HttpURLConnection c = (HttpURLConnection) (new URL("http://strawpoll.me/api/v2/polls")
                .openConnection());

        c.setRequestMethod("POST");
        c.setRequestProperty("Content-Type", "application/json");
        c.setRequestProperty("User-Agent", "CB2");

        c.setDoOutput(true);
        c.setDoInput(true);
        c.setUseCaches(false);

        String queryString = urlString;

        c.setRequestProperty("Content-Length", Integer.toString(queryString.length()));

        DataOutputStream wr = new DataOutputStream(c.getOutputStream());
        wr.writeBytes(queryString);

        wr.flush();
        wr.close();

        Scanner inStream = new Scanner(c.getInputStream());

        while (inStream.hasNextLine())
            line += (inStream.nextLine());

        inStream.close();
        System.out.println(line);
        try {
            JSONParser parser = new JSONParser();
            Object obj = parser.parse(line);
            JSONObject jsonObject = (JSONObject) obj;
            line = (Long) jsonObject.get("id") + "";

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

    } catch (MalformedURLException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
    }

    return line;
}

From source file:com.astifter.circatext.OpenWeatherMapJSONParser.java

@Override
public URL getURL(android.location.Location location, String cityName) {
    // api.openweathermap.org/data/2.5/weather?lat=35&lon=139
    String BASE_URL = "http://api.openweathermap.org/data/2.5/weather?units=metric&APPID=d9b53ed2098c82758e054eec0d9112d5&";
    String lat = "lat=" + Double.toString(location.getLatitude());
    String lon = "lon=" + Double.toString(location.getLongitude());
    try {//from   ww  w  .ja  v a2 s .  c o  m
        return new URL(BASE_URL + lat + "&" + lon);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.blogspot.jabelarminecraft.blocksmith.VersionChecker.java

@Override
public void run() {
    InputStream in = null;/*from   ww w .ja  va2s .c  o  m*/
    try {
        in = new URL(
                "https://raw.githubusercontent.com/jabelar/MagicBeans-1.7.10/master/src/main/java/com/blogspot/jabelarminecraft/magicbeans/version_file")
                        .openStream();
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        latestVersion = IOUtils.readLines(in).get(0); // toString(in);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(in);
    }
    System.out.println("Latest mod version = " + latestVersion);
    isLatestVersion = BlockSmith.MODVERSION.equals(latestVersion);
    System.out.println("Are you running latest version = " + isLatestVersion);
}

From source file:com.blogspot.jabelarminecraft.magicbeans.VersionChecker.java

@Override
public void run() {
    InputStream in = null;/*ww  w. jav a 2s.  c  o  m*/
    try {
        in = new URL(
                "https://raw.githubusercontent.com/jabelar/MagicBeans-1.7.10/master/src/main/java/com/blogspot/jabelarminecraft/magicbeans/version_file")
                        .openStream();
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        latestVersion = IOUtils.readLines(in).get(0); // toString(in);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(in);
    }
    System.out.println("Latest mod version = " + latestVersion);
    isLatestVersion = MagicBeans.MODVERSION.equals(latestVersion);
    System.out.println("Are you running latest version = " + isLatestVersion);
}

From source file:de.anneundsebp.ondemand.parser.fm4.Step1.java

List<Category> getCategories() {
    try {//  w  w w . j  a  va2s . com
        String page = Util.loadPage("http://audioapi.orf.at/fm4/json/2.0/broadcasts");
        return parseCategories(page);
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:main.java.com.omicronlab.avro.PhoneticXmlLoader.java

public PhoneticXmlLoader() {
    try {/* w  w w  .  j  a v a2s .c o  m*/
        this.url = new URL("D:\\phonetic.xml");
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.cellbots.communication.AppEngineCommChannel.java

private void resetConnection() {
    if (mHttpCmdUrl == null || mHttpCmdUrl.equals("")) {
        return;//from  www  .j ava2s.c o  m
    }
    try {
        mConnection = new HttpConnection(new URL(mHttpCmdUrl).getHost(), port);
        mConnection.open();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.arcbees.plugin.template.util.FetchProperties.java

/**
 * TODO retry on failures//from   w  ww  . j a va2s. c  o m
 * TODO report error
 * @throws MalformedURLException 
 * @throws ConfigurationException 
 */
public PropertiesConfiguration fetch() throws MalformedURLException, ConfigurationException {
    URL url;
    try {
        url = new URL(path);
    } catch (MalformedURLException e) {
        // TODO
        e.printStackTrace();
        throw e;
    }

    try {
        configuration = new PropertiesConfiguration(url);
    } catch (ConfigurationException e) {
        e.printStackTrace();
        throw e;
    }

    System.out.println(configuration.toString());

    return configuration;
}

From source file:com.blogspot.jabelarminecraft.movinglightsource.VersionChecker.java

@Override
public void run() {
    InputStream in = null;//from  w  w w  . ja  va 2s.c  om
    try {
        in = new URL(
                "https://raw.githubusercontent.com/jabelar/MovingLightSource-1.8/master/src/main/java/com/blogspot/jabelarminecraft/movinglightsource/version_file")
                        .openStream();
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        latestVersion = IOUtils.readLines(in).get(0); // toString(in);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(in);
    }
    // DEBUG
    System.out.println(
            "Current version is " + MovingLightSource.MODVERSION + " and latest version is " + latestVersion);
    isLatestVersion = MovingLightSource.MODVERSION.compareTo(latestVersion) >= 0;
    System.out.println("Are you running latest version = " + isLatestVersion);
}