List of usage examples for java.io IOException toString
public String toString()
From source file:com.streamsets.datacollector.websockets.LogMessageWebSocket.java
@Override public void onWebSocketConnect(final Session session) { super.onWebSocketConnect(session); synchronized (LogMessageWebSocket.class) { int maxClients = config.get(MAX_LOGTAIL_CONCURRENT_REQUESTS_KEY, MAX_LOGTAIL_CONCURRENT_REQUESTS_DEFAULT); if (logTailClients < maxClients) { logTailClients++;/*from w ww . j a v a2s . c om*/ } else { session.close(StatusCode.NORMAL, "Maximum concurrent connections reached"); return; } } TailerListener listener = new TailerListenerAdapter() { @Override public void handle(String line) { try { Map<String, String> namedGroupToValuesMap = logFileGrok.extractNamedGroups(line); if (namedGroupToValuesMap == null) { namedGroupToValuesMap = new HashMap<>(); namedGroupToValuesMap.put("exceptionMessagePart", line); } ObjectMapper objectMapper = ObjectMapperFactory.get(); String logDataJson = objectMapper.writer().writeValueAsString(namedGroupToValuesMap); session.getRemote().sendString(logDataJson); } catch (IOException ex) { LOG.warn("Error while sending log line through WebSocket message, {}", ex.toString(), ex); } } @Override public void fileNotFound() { LOG.warn("Log file '{}' does not exist", logFile); } @Override public void handle(Exception ex) { LOG.warn("Error while trying to read log file '{}': {}", logFile, ex.toString(), ex); } }; //TODO send -20K of logFile to session, separator line, then tailer tailer = new Tailer(new File(logFile), listener, 100, true, true); Thread thread = new Thread(tailer, "LogMessageWebSocket-tailLog"); thread.setDaemon(true); thread.start(); }
From source file:org.callimachusproject.xml.InputSourceResolver.java
@Override public Reader resolve(URI absoluteURI, String encoding, Configuration config) throws XPathException { try {/*from www . ja va2 s .c om*/ InputSource source = resolve(absoluteURI.toASCIIString()); if (encoding != null && encoding.length() > 0) { source.setEncoding(encoding); } return source.getCharacterStream(); } catch (IOException e) { throw new XPathException(e.toString(), e); } }
From source file:net.sourceforge.atunes.kernel.modules.player.vlcplayer.VlcTelnetClient.java
protected VlcTelnetClient(String newServer, int newPort) throws VlcTelnetClientException { // wait a title time for vlc process to be created try {/*from w w w . j a va 2s. c om*/ Thread.sleep(1000); } catch (InterruptedException e) { //we do nothing special //e.printStackTrace(); } // Connect to the specified server logger.debug(LogCategories.NETWORK, "VlcTelnetClient : Connecting to port : " + newPort + " on server : " + newServer); try { telnet.connect(newServer, newPort); } catch (SocketException se) { se.printStackTrace(); throw new VlcTelnetClientException( "Error while connecting to : " + newServer + " on : " + newPort + " : " + se.toString(), se); } catch (IOException ioe) { ioe.printStackTrace(); throw new VlcTelnetClientException( "Error while connecting to : " + newServer + " on : " + newPort + " : " + ioe.toString(), ioe); } // Get input and output stream references try { in = telnet.getInputStream(); out = new PrintStream(telnet.getOutputStream()); //throw new Exception("Can't write or read form telnet client"); } catch (Exception ex) { throw new VlcTelnetClientException("Can't write or read form telnet client", ex); } }
From source file:net.alchemiestick.katana.winehqappdb.WineApp.java
@Override protected String doInBackground(HttpUriRequest... url) { if (url[0] == null) return this.body; HttpResponse res = null;// w w w.j a v a 2s .c o m while (res == null) try { SearchView.do_sleep(500); res = this.client.execute(url[0]); } finally { continue; } while (res.getStatusLine() == null) { SearchView.do_sleep(500); } StringBuffer sb = new StringBuffer(""); try { BufferedReader br = new BufferedReader(new InputStreamReader(res.getEntity().getContent()), (2 * 1024)); String line; boolean first = true; while ((line = br.readLine()) != null) { if (first) { first = false; continue; } sb.append(line + "\n"); } this.body = sb.substring(sb.indexOf("<body"), (sb.lastIndexOf("</body>") + 7)); } catch (IOException ioe) { this.str = "IO Failed!!!:; ; ;"; this.str += ioe.toString(); } catch (Exception ex) { } finally { this.client.close(); } return this.body; }
From source file:com.thoughtworks.go.agent.service.AgentUpgradeService.java
void checkForUpgrade(String md5, String launcherMd5, String agentPluginsMd5) throws Exception { HttpMethod method = getAgentLatestStatusGetMethod(); try {/*from w w w . j a va 2 s . c o m*/ final int status = httpClient.executeMethod(method); if (status != 200) { LOGGER.error( String.format("[Agent Upgrade] Got status %d %s from Go", status, method.getStatusText())); return; } validateIfLatestAgent(md5, method); validateIfLatestLauncher(launcherMd5, method); validateIfLatestPluginZipAvailable(agentPluginsMd5, method); } catch (IOException ioe) { String message = String.format("[Agent Upgrade] Couldn't connect to: %s: %s", urlService.getAgentLatestStatusUrl(), ioe.toString()); LOGGER.error(message); LOGGER.debug(message, ioe); throw ioe; } finally { method.releaseConnection(); } }
From source file:org.powertac.samplebroker.core.BrokerPropertiesService.java
private boolean validXmlResource(Resource xml) { try {//from ww w .j ava 2 s . c o m log.info("Validating resource " + xml.getURI()); String path = xml.getURI().toString(); for (String regex : excludedPaths) { if (path.matches(regex)) { return false; } if (!xml.exists()) { log.warn("Resource " + xml.getURI() + " does not exist"); return false; } if (!xml.isReadable()) { log.warn("Resource " + xml.getURI() + " is not readable"); return false; } } return true; } catch (IOException e) { log.error("Should not happen: " + e.toString()); return false; } catch (Exception e) { log.error("Validation error " + e.toString()); e.printStackTrace(); return false; } }
From source file:de.intevation.test.irixservice.UploadReportTest.java
public void testReport(String reportFile) throws UploadReportException { ReportType report = getReportFromFile(reportFile); testObj.uploadReport(report);//w ww . j a va 2 s . c o m String uuid = report.getIdentification().getReportUUID(); String expectedPath = testObj.outputDir + "/" + uuid + ".xml"; String content1 = null; String content2 = null; try { Assert.assertTrue(new File(expectedPath).exists()); content1 = FileUtils.readFileToString(new File(reportFile), Charset.forName("utf-8")); content2 = FileUtils.readFileToString(new File(expectedPath), Charset.forName("utf-8")); } catch (IOException e) { Assert.fail(e.toString()); } if (content1.startsWith(UTF8_BOM)) { content1 = content1.substring(1); } try { Diff diff = new Diff(content1, content2); log.debug("Diff: " + diff.toString()); java.io.PrintWriter writer = new java.io.PrintWriter("/tmp/" + uuid + ".xml", "UTF-8"); writer.write(content2); writer.close(); Assert.assertTrue("Output differs", diff.similar()); } catch (IOException | SAXException e) { Assert.fail(e.toString()); } }
From source file:com.grendelscan.proxy.ssl.TunneledSSLConnection.java
@Override public void close() { LOGGER.debug("Shutting down socket"); open = false;//w w w.j a v a2 s . co m try { sslSocket.close(); } catch (IOException e) { LOGGER.trace("Problem closing ssl socket: " + e.toString(), e); } try { socket.close(); } catch (IOException e) { LOGGER.trace("Problem closing socket: " + e.toString(), e); } }
From source file:com.photon.phresco.nativeapp.unit.test.testcases.C_ProductListActivityTest.java
/** * Check products for available category id * *//*w w w.j a v a2 s . c om*/ @Test public final void testGetProductsForExistingCategoryId() { Product product = new Product(); int categoryId = 1; try { PhrescoLogger.info(TAG + " testGetProductsForExistingCategoryId -------------- START "); JSONObject productJSONObj = product.getProductJSONObject( Constants.getWebContextURL() + Constants.getRestAPI() + Constants.CATEGORIES_URL + categoryId); assertNotNull(productJSONObj); if (productJSONObj != null) { JSONArray productArray = productJSONObj.getJSONArray("product"); assertFalse("Products available for category " + categoryId, productArray.length() < 0); } PhrescoLogger.info(TAG + " testGetProductsForExistingCategoryId -------------- END "); } catch (IOException ex) { PhrescoLogger.info(TAG + "testGetProductsForExistingCategoryId - IOException: " + ex.toString()); PhrescoLogger.warning(ex); } catch (JSONException ex) { PhrescoLogger.info(TAG + "testGetProductsForExistingCategoryId - JSONException: " + ex.toString()); PhrescoLogger.warning(ex); } catch (Exception ex) { PhrescoLogger.info(TAG + "testGetProductsForExistingCategoryId - Exception: " + ex.toString()); PhrescoLogger.warning(ex); } }
From source file:com.photon.phresco.nativeapp.unit.test.testcases.C_ProductListActivityTest.java
/** * Check products for available category id * *//*w w w . j a v a 2 s . com*/ @Test public final void testGetProductsForNonExistingCategoryId() { Product product = new Product(); int categoryId = -1; try { PhrescoLogger.info(TAG + " testGetProductsForNonExistingCategoryId -------------- START "); JSONObject productJSONObj = product.getProductJSONObject( Constants.getWebContextURL() + Constants.getRestAPI() + Constants.CATEGORIES_URL + categoryId); assertNotNull(productJSONObj); if (productJSONObj != null && productJSONObj.optString("type") != null && productJSONObj.optString("type").equalsIgnoreCase("failure")) { // ErrorManager errorObj = PhrescoActivity.getErrorGSONObject(productJSONObj); assertTrue(productJSONObj.optString("message"), productJSONObj.optString("message") != null); } PhrescoLogger.info(TAG + " testGetProductsForNonExistingCategoryId -------------- END "); } catch (IOException ex) { PhrescoLogger.info(TAG + "testGetProductsForNonExistingCategoryId - IOException: " + ex.toString()); PhrescoLogger.warning(ex); } catch (Exception ex) { PhrescoLogger.info(TAG + "testGetProductsForNonExistingCategoryId - Exception: " + ex.toString()); PhrescoLogger.warning(ex); } }