List of usage examples for java.io IOException toString
public String toString()
From source file:io.bitsquare.seednode.SeedNodeMain.java
private void restart(BitsquareEnvironment environment) { stopped = true;/* w w w . j av a2 s.co m*/ seedNode.gracefulShutDown(() -> { try { final String[] tokens = environment.getAppDataDir().split("_"); String logPath = "error_" + (tokens.length > 1 ? tokens[tokens.length - 2] : "") + ".log"; RestartUtil.restartApplication(logPath); } catch (IOException e) { log.error(e.toString()); e.printStackTrace(); } finally { log.warn("Shutdown complete"); System.exit(0); } }); }
From source file:me.rgcjonas.portableMinecraftLauncher.ModdingClassLoader.java
public Class<?> findClass(String name) throws ClassNotFoundException { byte[] data = null; String resourceName = name.replace('.', '/').concat(".class"); //getResource expects this form if (moddedClasses.containsKey(name)) { data = moddedClasses.get(name);/*from w w w . ja v a 2 s .c o m*/ } else { try { InputStream is = this.getResourceAsStream(resourceName); if (is == null) { System.out.println("class not found: " + resourceName + "\n"); throw new ClassNotFoundException(); } data = IOUtils.toByteArray(is); } catch (IOException e) { throw new ClassNotFoundException(e.toString()); } } CodeSource source = new CodeSource(this.getResource(resourceName), new Certificate[] {}); return defineClass(name, data, 0, data.length, source); }
From source file:com.nubits.nubot.pricefeeds.OpenexchangeratesPriceFeed.java
@Override public LastPrice getLastPrice(CurrencyPair pair) { long now = System.currentTimeMillis(); long diff = now - lastRequest; if (diff >= refreshMinTime) { String url = getUrl(pair); String htmlString;//from ww w. j a v a 2s . c om try { htmlString = Utils.getHTML(url, true); } catch (IOException ex) { LOG.severe(ex.toString()); return new LastPrice(true, name, pair.getOrderCurrency(), null); } JSONParser parser = new JSONParser(); boolean found = false; try { JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString)); String lookingfor = pair.getOrderCurrency().getCode().toUpperCase(); JSONObject rates = (JSONObject) httpAnswerJson.get("rates"); lastRequest = System.currentTimeMillis(); if (rates.containsKey(lookingfor)) { double last = (Double) rates.get(lookingfor); last = Utils.round(1 / last, 8); lastPrice = new LastPrice(false, name, pair.getOrderCurrency(), new Amount(last, pair.getPaymentCurrency())); return lastPrice; } else { LOG.warning("Cannot find currency :" + lookingfor + " on feed :" + name); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } catch (ParseException ex) { LOG.severe(ex.toString()); lastRequest = System.currentTimeMillis(); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } else { LOG.fine("Wait " + (refreshMinTime - (System.currentTimeMillis() - lastRequest)) + " ms " + "before making a new request. Now returning the last saved price\n\n"); return lastPrice; } }
From source file:de.hybris.platform.marketplaceintegrationbackoffice.renderer.MarketplaceStoreTokenRefreshRenderer.java
private void refreshOrderDownload(final MarketplaceStoreModel model) { final MarketplaceSellerModel seller = model.getMarketplaceSeller(); final MarketplaceModel marketplace = seller.getMarketplace(); modelService.refresh(seller);/*w w w. ja va 2 s .c o m*/ final String requestUrl = marketplace.getAdapterUrl() + Labels.getLabel("marketplace.refresh.token.path") + Labels.getLabel("marketplace.refresh.token.path.parameter") + model.getIntegrationId(); try { marketplaceClient.redirectRequest(requestUrl); } catch (final IOException e) { LOG.error(e.toString()); // YTODO log process need to be implemented marketplaceLogger.log(e.toString()); } }
From source file:CookieMIDlet.java
public void run() { String url = getAppProperty("CookieMIDlet-URL"); try {/*from w w w . j ava2 s .co m*/ // Query the server and retrieve the response. HttpConnection hc = (HttpConnection) Connector.open(url); if (mSession != null) hc.setRequestProperty("cookie", mSession); InputStream in = hc.openInputStream(); String cookie = hc.getHeaderField("Set-cookie"); if (cookie != null) { int semicolon = cookie.indexOf(';'); mSession = cookie.substring(0, semicolon); } int length = (int) hc.getLength(); byte[] raw = new byte[length]; in.read(raw); String s = new String(raw); Alert a = new Alert("Response", s, null, null); a.setTimeout(Alert.FOREVER); mDisplay.setCurrent(a, mForm); in.close(); hc.close(); } catch (IOException ioe) { Alert a = new Alert("Exception", ioe.toString(), null, null); a.setTimeout(Alert.FOREVER); mDisplay.setCurrent(a, mForm); } }
From source file:com.apporiented.hermesftp.cmd.AbstractFtpCmdPort.java
/** * {@inheritDoc}/* w ww. j av a2s . co m*/ */ public void execute() throws FtpCmdException { try { String args = getArguments(); if (args.length() == 0) { msgOut(MSG501); return; } int protocolIdx = doReadProtocolIdx(args); String addr = doReadIPAddr(args); int port = doReadPort(args); log.debug("Data Channel Protocol: " + protocolIdx + ", IPAddr: " + addr + ", port: " + port); setupDataChannel(protocolIdx, addr, port); msgOut(MSG200); } catch (IOException e) { log.error(e.toString()); msgOut(MSG500); } catch (IllegalArgumentException e) { log.error(e.toString()); msgOut(MSG501); } }
From source file:io.bitsquare.statistics.StatisticsMain.java
private void restart(BitsquareEnvironment environment) { stopped = true;//from w ww . j a v a 2 s . com statistics.gracefulShutDown(() -> { try { final String[] tokens = environment.getAppDataDir().split("_"); String logPath = "error_" + (tokens.length > 1 ? tokens[tokens.length - 2] : "") + ".log"; RestartUtil.restartApplication(logPath); } catch (IOException e) { log.error(e.toString()); e.printStackTrace(); } finally { log.warn("Shutdown complete"); System.exit(0); } }); }
From source file:com.nubits.nubot.pricefeeds.feedservices.OpenexchangeratesPriceFeed.java
@Override public LastPrice getLastPrice(CurrencyPair pair) { long now = System.currentTimeMillis(); long diff = now - lastRequest; if (diff >= refreshMinTime) { String url = getUrl(pair); String htmlString;//from ww w .j av a 2s . c o m try { LOG.trace("feed fetching from URL: " + url); htmlString = Utils.getHTML(url, true); } catch (IOException ex) { LOG.error(ex.toString()); return new LastPrice(true, name, pair.getOrderCurrency(), null); } JSONParser parser = new JSONParser(); boolean found = false; try { JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString)); String lookingfor = pair.getOrderCurrency().getCode().toUpperCase(); JSONObject rates = (JSONObject) httpAnswerJson.get("rates"); lastRequest = System.currentTimeMillis(); if (rates.containsKey(lookingfor)) { double last = (Double) rates.get(lookingfor); LOG.trace("last " + last); last = Utils.round(1 / last, 8); lastPrice = new LastPrice(false, name, pair.getOrderCurrency(), new Amount(last, pair.getPaymentCurrency())); return lastPrice; } else { LOG.warn("Cannot find currency :" + lookingfor + " on feed :" + name); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } catch (ParseException ex) { LOG.error(ex.toString()); lastRequest = System.currentTimeMillis(); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } else { LOG.warn("Wait " + (refreshMinTime - (System.currentTimeMillis() - lastRequest)) + " ms " + "before making a new request. Now returning the last saved price\n\n"); return lastPrice; } }
From source file:hochschuledarmstadt.photostream_tools.StorePhotoAsyncTask.java
@Override protected Photo doInBackground(JSONObject... params) { try {/*from w w w. ja v a2s . c o m*/ return uploadPhoto(params[0]); } catch (IOException e) { Logger.log(TAG, LogLevel.ERROR, e.toString()); postError(new HttpError(-1, e.toString())); } catch (HttpPhotoStreamException e) { Logger.log(TAG, LogLevel.ERROR, e.toString()); postError(e.getHttpError()); } return null; }
From source file:com.altamob.ads.connect.request.RequestAsyncTask.java
public void execute() { Executors.newCachedThreadPool().execute(new Runnable() { @Override/*from w w w .j ava 2 s . c o m*/ public void run() { // Log.i(TAG, String.valueOf(requestCounter)); String result = ""; try { // Log.i("requestJson", // BuildJsonUtil.buridAdRequestJson(request)); result = HttpUtil.httpGet(buildGetUrl(), request.getToken(), requestTimeOut); JSONObject jsonObject = new JSONObject(result); if (jsonObject.has("error")) { Log.e(TAG, "Ad Service error:" + jsonObject.getString("error")); callBack.OnFailure(AdError.SERVER_ERROR); } else { callBack.OnCompleted(result); } } catch (IOException e) { Log.e(TAG, e.toString()); e.printStackTrace(); callBack.OnFailure(AdError.NETWORK_ERROR); } catch (Exception e) { Log.e(TAG, e.toString()); e.printStackTrace(); callBack.OnFailure(AdError.SERVER_ERROR); } } }); }