List of usage examples for java.net UnknownServiceException printStackTrace
public void printStackTrace()
From source file:com.protheos.graphstream.JSONSender.java
/** * Send JSONObject message to Gephi server * //from www.j a v a 2s. com * @param obj * , the JSON message content * @param operation * , the operation sending to the server, like "updateGraph", * "getGraph" */ private void doSend(JSONObject obj, String operation) { try { URL url = new URL("http", host, port, "/" + workspace + "?operation=" + operation + "&format=JSON"); URLConnection connection = url.openConnection(); connection.setDoOutput(true); connection.connect(); OutputStream outputStream = null; PrintStream out = null; try { outputStream = connection.getOutputStream(); out = new PrintStream(outputStream, true); out.print(obj.toString() + EOL); out.flush(); out.close(); // send event message to the server and read the result from the // server InputStream inputStream = connection.getInputStream(); BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream)); String line; while ((line = bf.readLine()) != null) { // if (debug) debug(line); } inputStream.close(); } catch (UnknownServiceException e) { // protocol doesn't support output e.printStackTrace(); return; } } catch (IOException ex) { ex.printStackTrace(); } }