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:at.ac.tuwien.infosys.repository.LocalComponentRepository.java

protected List<Resource> createResources(List<Path> resources) {
    List<Resource> result = new ArrayList<Resource>();

    for (Path path : resources) {
        Resource resource = new Resource();
        resource.setName(path.getFileName().toString());
        try {/* ww  w  .j  a va 2  s.  c o  m*/
            resource.setUri(path.toUri().toURL());
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        result.add(resource);
    }
    return result;
}

From source file:org.imaginationforpeople.android2.model.Picture.java

public Bitmap getImageBitmap() {
    if (imageBitmap == null) {
        String path;/*from  w w  w .  ja  va 2s .  c o m*/
        try {
            path = new URL(imageUrl).getPath();
            FileInputStream file = DataHelper.openFileInput(
                    DataHelper.FILE_PREFIX_PROJECT_IMAGE + path.substring(path.lastIndexOf('/') + 1));
            imageBitmap = BitmapFactory.decodeStream(file);
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return null;
        }
    }
    return imageBitmap;
}

From source file:com.piusvelte.webcaster.MediaLoader.java

public MediaLoader(Context context, String host) {
    super(context);

    if (host != null) {

        try {//from  w w w. j  a  va2 s . com
            mediaUrl = new URL(String.format(MEDIA_LIBRARY_URL_FORMAT, host));
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:eu.codeplumbers.cosi.api.tasks.DeleteDocumentTask.java

@Override
protected String doInBackground(Void... voids) {
    URL urlO = null;/* w ww  . j  av a2  s.co  m*/
    try {
        urlO = new URL(url + remoteId + "/");
        HttpURLConnection conn = (HttpURLConnection) urlO.openConnection();
        conn.setConnectTimeout(5000);
        conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
        conn.setRequestProperty("Authorization", authHeader);
        conn.setDoOutput(false);
        conn.setDoInput(true);

        conn.setRequestMethod("DELETE");

        // read the response
        InputStream in = new BufferedInputStream(conn.getInputStream());

        StringWriter writer = new StringWriter();
        IOUtils.copy(in, writer, "UTF-8");
        result = writer.toString();

        in.close();
        conn.disconnect();

    } catch (MalformedURLException e) {
        result = "error";
        e.printStackTrace();
        errorMessage = e.getLocalizedMessage();
    } catch (ProtocolException e) {
        result = "error";
        errorMessage = e.getLocalizedMessage();
        e.printStackTrace();
    } catch (IOException e) {
        result = "error";
        errorMessage = e.getLocalizedMessage();
        e.printStackTrace();
    }

    return result;
}

From source file:com.piusvelte.webcaster.MediaLoader.java

public void loadHost(String host) {
    if (host != null) {
        try {//w w  w. j ava 2s  .co m
            mediaUrl = new URL(String.format(MEDIA_LIBRARY_URL_FORMAT, host));
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        forceLoad();
    } else {
        mediaUrl = null;
    }
}

From source file:org.imaginationforpeople.android2.model.Picture.java

public Bitmap getThumbBitmap() {
    if (thumbBitmap == null) {
        String path;//from   w  ww .  j a  v a 2s. c  o m
        try {
            path = new URL(thumbUrl).getPath();
            if (DataHelper.checkThumbFile(thumbUrl)) {
                FileInputStream file = DataHelper.openFileInput(
                        DataHelper.FILE_PREFIX_PROJECT_THUMB + path.substring(path.lastIndexOf('/') + 1));
                thumbBitmap = BitmapFactory.decodeStream(file);
            } else
                return null;
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return null;
        }
    }
    return thumbBitmap;
}

From source file:com.falcon.orca.handlers.MasterHandler.java

@Override
public void handle() {

    final ActorRef clusterManager = actorSystem.actorOf(ClusterManager.props(this.minimumNodes, hostname));

    //Register the local nodeManager
    //TODO: host and port should not be required in local nodeManager case
    final ActorRef localNodeManager = actorSystem.actorOf(NodeManager.props(hostname, 2552));
    NodeManagerCommand nodeManagerCommand = new NodeManagerCommand();
    nodeManagerCommand.setType(NodeManagerCommandType.REGISTER_TO_MASTER);
    localNodeManager.tell(nodeManagerCommand, clusterManager);

    //Read the input on console and take decision.
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
    Options options = createMasterOptions();
    printOnCmd("Welcome to ORCA type help to see what ORCA can do. You have started the node in master mode.");
    try {/*from www  .  j av a  2  s.  c o  m*/
        String command = br.readLine();
        while (command != null) {
            if (!StringUtils.isEmpty(command)) {
                try {
                    String[] treatedCommandParts = treatCommands(command);
                    commandLine = commandLineParser.parse(options, treatedCommandParts);
                    if (commandLine.hasOption("start")) {
                        RunDetails runDetails = createRunDetails(commandLine);
                        ClusterManagerCommand clusterManagerCommand = new ClusterManagerCommand();
                        clusterManagerCommand.setType(ClustermanagerCommandType.START_LOAD);
                        clusterManagerCommand.putOnContext("runDetails", runDetails);
                        clusterManager.tell(clusterManagerCommand, clusterManager);
                    } else if (commandLine.hasOption("stop")) {
                        ClusterManagerCommand clusterManagerCommand = new ClusterManagerCommand();
                        clusterManagerCommand.setType(ClustermanagerCommandType.STOP_LOAD);
                        clusterManager.tell(clusterManagerCommand, clusterManager);
                    } else if (commandLine.hasOption("exit")) {
                        ClusterManagerCommand clusterManagerCommand = new ClusterManagerCommand();
                        clusterManagerCommand.setType(ClustermanagerCommandType.EXIT);
                        clusterManager.tell(clusterManagerCommand, clusterManager);
                        actorSystem.shutdown();
                        actorSystem.awaitTermination(new FiniteDuration(1, TimeUnit.MINUTES));
                        break;
                    } else if (commandLine.hasOption("pause")) {
                        ClusterManagerCommand clusterManagerCommand = new ClusterManagerCommand();
                        clusterManagerCommand.setType(ClustermanagerCommandType.PAUSE_LOAD);
                        clusterManager.tell(clusterManagerCommand, clusterManager);
                    } else if (commandLine.hasOption("resume")) {
                        ClusterManagerCommand clusterManagerCommand = new ClusterManagerCommand();
                        clusterManagerCommand.setType(ClustermanagerCommandType.RESUME_LOAD);
                        clusterManager.tell(clusterManagerCommand, clusterManager);
                    } else if (commandLine.hasOption("clusterDetails")) {
                        ClusterManagerCommand clusterManagerCommand = new ClusterManagerCommand();
                        clusterManagerCommand.setType(ClustermanagerCommandType.CLUSTER_DETAILS);
                        clusterManager.tell(clusterManagerCommand, clusterManager);
                    } else {
                        printOnCmd(printHelpMasterMode());
                    }
                } catch (ParseException pe) {
                    printOnCmd(printHelpMasterMode());
                } catch (MalformedURLException me) {
                    me.printStackTrace();
                }
            } else {
                printOnCmd("", false);
            }
            command = br.readLine();
        }
    } catch (IOException e) {
        printOnCmd("Failed to read your command, try again.");
    }
}

From source file:edu.harvard.i2b2.fhirserver.ws.FileServlet.java

public void init() throws ServletException {

    // Define base path somehow. You can define it as init-param of the servlet.
    try {/* ww  w . j  a v a 2s .co m*/
        this.basePath = this.getServletContext().getResource("/").toString();
        this.basePath = this.basePath.substring(0, this.basePath.length() - 1);
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    // In a Windows environment with the Applicationserver running on the
    // c: volume, the above path is exactly the same as "c:\files".
    // In UNIX, it is just straightforward "/files".
}

From source file:com.google.android.panoramio.BitmapUtilsTask.java

/**
 * Loads a bitmap from the specified url.
 * //from  w ww  .  jav  a 2  s .  c om
 * @param url The location of the bitmap asset
 * @return The bitmap, or null if it could not be loaded
 */
public Bitmap loadThumbnail(String string) {
    Bitmap bitmap = null;

    InputStream is;
    try {
        is = (InputStream) new URL(string).getContent();
        BitmapFactory.Options optsDownSample = new BitmapFactory.Options();
        bitmap = BitmapFactory.decodeStream(is, null, optsDownSample);

    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return bitmap;
}

From source file:edu.brandeis.cs.planner.service.Metadata.java

protected void init() {
    boolean use_proxy = ConfigXML.config().getBoolean("connection/proxies/use_proxy");
    if (use_proxy) {
        client.setProxy(ConfigXML.config().getString("connection/proxies/http_proxy"));
    }//from   w  w w .  ja  v a  2s.c  om
    String service_manager = ConfigXML.config().getString("grids/grid/service_manager");
    try {
        URL url = new URL(service_manager);
        String host = url.getHost();
        int port = url.getPort();
        username = ConfigXML.config().getString(
                "connection/credentials/credential[@host='" + host + "' and @port='" + port + "']/username");
        password = ConfigXML.config().getString(
                "connection/credentials/credential[@host='" + host + "' and @port='" + port + "']/password");
        logger.debug("host={}", host);
        logger.debug("port={}", port);
        logger.debug("username={}", username);
    } catch (MalformedURLException e) {
        logger.warn("Wrong Service Manager", e);
        e.printStackTrace();
    }
    for (String wsdlString : wsdls) {
        String metadataString = callMetadata(wsdlString);
        metadataJsons.add(metadataString);
    }
}