Example usage for java.net URISyntaxException printStackTrace

List of usage examples for java.net URISyntaxException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:io.samsungsami.example.samiiotsimplecontroller.SAMISession.java

private void createLiveWebsocket() {
    try {/*  w  w w  . ja  v a2s  .co m*/
        mLive = new FirehoseWebSocket(DEVICE_TOKEN, DEVICE_ID, null, null, new SamiWebSocketCallback() {
            @Override
            public void onOpen(short i, String s) {
                Log.d(TAG, "connectLiveWebsocket: onOpen()");
                final Intent intent = new Intent(WEBSOCKET_LIVE_ONOPEN);
                LocalBroadcastManager.getInstance(ourContext).sendBroadcast(intent);
            }

            @Override
            public void onMessage(MessageOut messageOut) {
                Log.d(TAG, "connectLiveWebsocket: onMessage(" + messageOut.toString() + ")");
                final Intent intent = new Intent(WEBSOCKET_LIVE_ONMSG);
                intent.putExtra(SDID, messageOut.getSdid());
                intent.putExtra(DEVICE_DATA, messageOut.getData().toString());
                intent.putExtra(TIMESTEP, messageOut.getTs().toString());
                LocalBroadcastManager.getInstance(ourContext).sendBroadcast(intent);
            }

            @Override
            public void onAction(ActionOut actionOut) {
            }

            @Override
            public void onAck(Acknowledgement acknowledgement) {
            }

            @Override
            public void onClose(int code, String reason, boolean remote) {
                final Intent intent = new Intent(WEBSOCKET_LIVE_ONCLOSE);
                intent.putExtra("error", "mLive is closed. code: " + code + "; reason: " + reason);
                LocalBroadcastManager.getInstance(ourContext).sendBroadcast(intent);
            }

            @Override
            public void onError(Error ex) {
                final Intent intent = new Intent(WEBSOCKET_LIVE_ONERROR);
                intent.putExtra("error", "mLive error: " + ex.getMessage());
                LocalBroadcastManager.getInstance(ourContext).sendBroadcast(intent);
            }
        });
    } catch (URISyntaxException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.streamdataio.android.stockmarket.StockMarketList.java

/**
 * Create the EventSource object & start listening SSE incoming messages
 *//*  w  w  w  . j  a  va  2s .c o m*/
private void connect() {
    // Create headers : Add the streamdata.io app token
    Map<String, String> headers = new HashMap<String, String>();
    headers.put("X-Sd-Token", streamdataioAppToken);

    // Create the EventSource with API URL & Streamdata.io authentication token
    try {
        String targetUrl = streamdataioProxyPrefix + myApi;
        eventSource = new EventSource(new URI(targetUrl), new URI(myApi), new SSEHandler(), headers);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    // Start data receiving
    //eventSource.connect();
}

From source file:com.sshtools.appframework.ui.IconStore.java

public void addThemeJar(String themeName) throws IOException {
    FileObject obj = null;//  www .  j  a va2 s  .c  om
    try {
        obj = VFS.getManager().resolveFile("res:" + themeName + "/index.theme");
    } catch (Exception e) {
        URL loc = getClass().getClassLoader().getResource(themeName + "/index.theme");
        try {
            String sloc = loc.toURI().toString();
            if (sloc.startsWith("jar:file:/") || !sloc.startsWith("jar:file://")) {
                sloc = "jar:jar:/" + System.getProperty("user.dir") + sloc.substring(9);
                FileObject resolveFile = VFS.getManager().resolveFile(System.getProperty("user.dir"));
                obj = VFS.getManager().resolveFile(resolveFile, sloc);
            } else {
                obj = VFS.getManager().resolveFile(sloc);

            }
        } catch (URISyntaxException e1) {
            e1.printStackTrace();
        }
    }
    if (obj != null) {
        iconService.addBase(obj.getParent().getParent());
    }
}

From source file:fr.gael.dhus.server.ftp.service.DHuSVFSService.java

public String normalizePath(String path) {
    try {/*  w  w  w . ja v  a2 s.co m*/
        return new URI(null, null, path, null).normalize().getPath();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    return path;
}

From source file:com.stratio.morphlines.refererparser.Parser.java

private Map<String, String> buildParamsMap(String query) {
    List<NameValuePair> params = null;
    try {/*from  ww w. j  a v a2 s.  com*/
        params = URLEncodedUtils.parse(new URI(HTTP_LOCALHOST + query), "UTF-8");
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    Map<String, String> paramsMap = new HashMap<String, String>();
    for (NameValuePair param : params) {
        paramsMap.put(param.getName(), param.getValue());

    }
    return paramsMap;
}

From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientSP.java

/**
 * Starts the automatic eco-assessment of a service.
 *
 * @param serviceId Service identifier./*from   w  w w  .  j  a v  a 2s  .c  om*/
 * @param timeout Timeout between successive ecoefficiency automatic
 * assessments. A default timeout value will be used if this parameter is
 * not specified.
 */
public void startAssessment(String serviceId, Long timeout) {
    try {
        if (serviceId != null) {
            WebResource resource = client.resource(this.getAddress()).path("service").path(serviceId);
            if (timeout != null) {
                resource = resource.queryParam("timeout", timeout.toString());
            }
            resource.post();
        }
    } catch (UniformInterfaceException ex) {
        ClientResponse cr = ex.getResponse();
        log.error(cr.getStatus());
        ex.printStackTrace();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
}

From source file:co.adrianblan.noraoke.SongNowPlayingFragment.java

private void connectWebSocket() {
    URI uri;//from   w w  w .ja  va 2 s  . c  om
    try {
        //URL to a DigitalOcean instance in Singapore, dedicated to Noraoke
        uri = new URI("ws://128.199.134.30:8000/");
    } catch (URISyntaxException e) {
        e.printStackTrace();
        return;
    }

    System.out.println("Opening socket");

    mWebSocketClient = new WebSocketClient(uri) {
        @Override
        public void onOpen(ServerHandshake serverHandshake) {
            Log.i("Websocket", "Opened");
            mWebSocketClient.send("HELLO");
        }

        @Override
        public void onMessage(String s) {
            final String message = s;

            //Thread?
            System.out.println(message);

            //If it's connection messages we quit
            if (message.contains("HELLO") || message.contains("connected")) {
                return;
            }

            //If the others pause, we pause too
            if (message.contains("STOP")) {
                mPlayer.pause();
                return;
            }

            //Otherwise we need to seek to their position

            //The strings are split into three parts by " - " as token
            String[] result = message.split("\\s-\\s");

            //The first part is IP, the second the time it was played and third where in the song it was played
            if (result.length != 3) {
                return;
            }

            //Get the time in milliseconds
            //long timeshift = (System.currentTimeMillis() - Long.parseLong(result[1]));
            long timeshift = 250;
            int seekTo = Integer.parseInt(result[2]) + (int) timeshift;

            System.out.println("timeshift: " + timeshift + " + " + Integer.parseInt(result[2]));

            //The seek must be fitting within the song
            if (seekTo >= 0 && seekTo < mPlayer.getDuration()) {
                mPlayer.seekTo(seekTo);

                //If it's not playing, start
                if (!mPlayer.isPlaying()) {

                    //Only play if activity is in foreground
                    if (MainActivity.isInForeground()) {
                        mPlayer.start();
                    }
                }
            }

        }

        @Override
        public void onClose(int i, String s, boolean b) {
            Log.i("Websocket", "Closed " + s);
        }

        @Override
        public void onError(Exception e) {
            Log.i("Websocket", "Error " + e.getMessage());
        }
    };
    mWebSocketClient.connect();
}

From source file:com.ibm.watson.developer_cloud.android.speech_to_text.v1.SpeechToText.java

/**
 * Start recording audio/*w w  w  . j a  va2 s .  c o m*/
 */
public void recognize() {
    Log.d(TAG, "recognize");
    try {
        HashMap<String, String> header = new HashMap<String, String>();
        header.put("Content-Type", sConfig.audioFormat);

        if (sConfig.isAuthNeeded) {
            if (this.tokenProvider != null) {
                header.put("X-Watson-Authorization-Token", this.tokenProvider.getToken());
                Log.d(TAG, "ws connecting with token based authentication");
            } else {
                String auth = "Basic " + Base64
                        .encodeBytes((this.username + ":" + this.password).getBytes(Charset.forName("UTF-8")));
                header.put("Authorization", auth);
                Log.d(TAG, "ws connecting with Basic Authentication");
            }
        }

        String wsURL = getHostURL().toString() + "/v1/recognize"
                + (this.model != null ? ("?model=" + this.model) : "");

        uploader = new WebSocketUploader(wsURL, header, sConfig);
        uploader.setDelegate(this.delegate);
        this.startRecording();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
}

From source file:client.AsterixDBClient.java

private void initialize() {
    try {//from   ww w  . ja  va2  s . c o m
        String cc = (String) config.getParamValue(Constants.CC_URL);
        int port = Constants.DEFAULT_PORT;
        if (config.isParamSet(Constants.PORT)) {
            port = (int) config.getParamValue(Constants.PORT);
        }
        String qLang = (String) config.getParamValue(Constants.QUERY_LANG);
        switch (qLang) {
        case Constants.AQL:
            roBuilder = new URIBuilder("http://" + cc + ":" + port + Constants.AQL_URL_SUFFIX);
            break;
        case Constants.SQLPP:
            roBuilder = new URIBuilder("http://" + cc + ":" + port + Constants.SQLPP_URL_SUFFIX);
            break;
        default:
            System.err.println("Invalid Query Language: " + qLang + " (Valid values are " + Constants.AQL
                    + " and " + Constants.SQLPP + " ).");
            return;
        }

        httpclient = new DefaultHttpClient();
        httpGet = new HttpGet();

        iterations = (int) config.getParamValue(Constants.ITERATIONS);

        String workloadFilePath = config.getHomePath() + "/" + Constants.WORKLOAD_FILE;
        loadWorkload(workloadFilePath);

        String statsFile = config.getHomePath() + "/" + Constants.DEFAULT_STATS_FILE;
        if (config.isParamSet(Constants.STATS_FILE)) {
            statsFile = (String) config.getParamValue(Constants.STATS_FILE);
        }
        pw = new PrintWriter(statsFile);
        DateFormat df = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss");
        Date dateobj = new Date();
        String currentTime = df.format(dateobj);
        pw.println(currentTime); //Add the test time as the header
        pw.println("\nIteration\tQName\tTime"); //TSV header

        rw = null;
        if (config.isParamSet(Constants.RESULTS_FILE)) {
            String resultsFile = (String) config.getParamValue(Constants.RESULTS_FILE);
            rw = new PrintWriter(resultsFile);
        }
    } catch (URISyntaxException e) {
        System.err.println("Issue(s) in initializing the HTTP client");
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        System.err.println("Issue in initializing printWriter(s)");
        e.printStackTrace();
    }
}