Example usage for java.io IOException toString

List of usage examples for java.io IOException toString

Introduction

In this page you can find the example usage for java.io IOException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.terasoluna.gfw.functionaltest.app.ScreenCapture.java

public void saveForced(WebDriver webDriver, String subTitle) {

    TakesScreenshot takesScreenshot = null;
    if (webDriver instanceof TakesScreenshot) {
        takesScreenshot = (TakesScreenshot) webDriver;
    }/*from ww  w.j a  va2s .c  o  m*/
    if (takesScreenshot == null) {
        logger.warn("WebDriver is not supported screenshot. WebDeiver is {}.", webDriver);
        return;
    }

    if (StringUtils.isEmpty(subTitle)) {
        subTitle = "";
    } else {
        subTitle = "-" + subTitle;
    }

    File screenshotFile = takesScreenshot.getScreenshotAs(OutputType.FILE);

    int sequenceNo = sequence.incrementAndGet();
    String evidenceFile = String.format("screen_capture_%03d%s.png", sequenceNo, subTitle);

    try {
        FileUtils.copyFile(screenshotFile, new File(evidenceSavingDirectory, evidenceFile));
    } catch (IOException e) {
        logger.error(e.toString());
    }

}

From source file:com.nubits.nubot.pricefeeds.CoinmarketcapnexuistPriceFeed.java

@Override
public LastPrice getLastPrice(CurrencyPair pair) {

    long now = System.currentTimeMillis();
    long diff = now - lastRequest;
    if (diff >= refreshMinTime) {
        String htmlString;//w  w  w. j  a v a 2  s .  c  o  m
        try {
            htmlString = Utils.getHTML(getUrl(pair), true);
        } catch (IOException ex) {
            LOG.severe(ex.toString());
            return new LastPrice(true, name, pair.getOrderCurrency(), null);
        }
        JSONParser parser = new JSONParser();
        try {
            JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString));
            JSONObject price = (JSONObject) httpAnswerJson.get("price");
            double last = Utils.getDouble(price.get("usd"));
            lastRequest = System.currentTimeMillis();
            lastPrice = new LastPrice(false, name, pair.getOrderCurrency(),
                    new Amount(last, pair.getPaymentCurrency()));
            return lastPrice;
        } catch (Exception 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:com.nubits.nubot.pricefeeds.feedservices.CoinmarketcapnexuistPriceFeed.java

@Override
public LastPrice getLastPrice(CurrencyPair pair) {

    long now = System.currentTimeMillis();
    long diff = now - lastRequest;
    if (diff >= refreshMinTime) {
        String htmlString;//from ww w . j a  v a  2s .  com
        try {
            htmlString = Utils.getHTML(getUrl(pair), true);
        } catch (IOException ex) {
            LOG.error(ex.toString());
            return new LastPrice(true, name, pair.getOrderCurrency(), null);
        }
        JSONParser parser = new JSONParser();
        try {
            JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString));
            JSONObject price = (JSONObject) httpAnswerJson.get("price");
            double last = Utils.getDouble(price.get("usd"));
            lastRequest = System.currentTimeMillis();
            lastPrice = new LastPrice(false, name, pair.getOrderCurrency(),
                    new Amount(last, pair.getPaymentCurrency()));
            return lastPrice;
        } catch (Exception 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:com.trenako.web.controllers.admin.AdminOptionsController.java

@RequestMapping(method = RequestMethod.POST)
public String create(OptionForm form, BindingResult bindingResult, ModelMap model,
        RedirectAttributes redirectAtts) {
    if (bindingResult.hasErrors()) {
        model.addAttribute("newForm", form);
        return "option/new";
    }/*from   w  w  w  . java  2  s .com*/

    Option option;
    try {
        option = form.buildOption();
        service.save(option);
        OPTION_CREATED_MSG.appendToRedirect(redirectAtts);
        return "redirect:/admin/options";

    } catch (IOException e) {
        log.error(e.toString());
    }

    model.addAttribute("newForm", form);
    return "option/new";
}

From source file:com.nubits.nubot.pricefeeds.BtcePriceFeed.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.  ja v  a  2 s . c o m*/
        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();
        try {
            JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString));
            JSONObject tickerObject = (JSONObject) httpAnswerJson.get("ticker");
            double last = Utils.getDouble(tickerObject.get("last"));

            lastRequest = System.currentTimeMillis();
            lastPrice = new LastPrice(false, name, pair.getOrderCurrency(),
                    new Amount(last, pair.getPaymentCurrency()));
            return lastPrice;
        } catch (Exception ex) {
            LOG.severe(htmlString);
            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:com.nubits.nubot.pricefeeds.feedservices.BtcePriceFeed.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  w  ww.ja  v a  2  s.com*/
        try {
            htmlString = Utils.getHTML(url, true);
        } catch (IOException ex) {
            LOG.error(ex.toString());
            return new LastPrice(true, name, pair.getOrderCurrency(), null);
        }
        JSONParser parser = new JSONParser();
        try {
            JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString));
            JSONObject tickerObject = (JSONObject) httpAnswerJson.get("ticker");
            double last = Utils.getDouble(tickerObject.get("last"));

            lastRequest = System.currentTimeMillis();
            lastPrice = new LastPrice(false, name, pair.getOrderCurrency(),
                    new Amount(last, pair.getPaymentCurrency()));
            return lastPrice;
        } catch (Exception ex) {
            LOG.error(htmlString);
            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:com.streamsets.lib.security.http.PlainSSOTokenGenerator.java

protected String generateData(SSOUserPrincipal principal) {
    try {//from w w w. j av  a2s . com
        String data = OBJECT_MAPPER.writeValueAsString(principal);
        return Base64.encodeBase64String(data.getBytes());
    } catch (IOException ex) {
        throw new RuntimeException(Utils.format("Should never happen: {}", ex.toString(), ex));
    }
}

From source file:org.deviceconnect.android.client.fragment.TextDialogFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    mLogger.entering(getClass().getName(), "onCreateView",
            new Object[] { inflater, container, savedInstanceState });

    View view = inflater.inflate(R.layout.fragment_privacypolicy, null);
    TextView text = (TextView) view.findViewById(android.R.id.text1);

    InputStream is = null;// w  w w .ja  v a 2 s  .c  o m
    try {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        is = getActivity().getResources().openRawResource(getArguments().getInt(Intent.EXTRA_TEXT));
        byte[] buf = new byte[BUFFER_SIZE];
        while (true) {
            int len = is.read(buf);
            if (len < 0) {
                break;
            }
            os.write(buf, 0, len);
        }
        text.setText(new String(os.toByteArray(), HTTP.UTF_8));
    } catch (IOException e) {
        mLogger.warning(e.toString());
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                mLogger.fine(e.toString());
            }
        }
    }

    getDialog().setTitle(getArguments().getInt(Intent.EXTRA_TITLE));

    mLogger.exiting(getClass().getName(), "onCreateView", view);
    return view;
}

From source file:com.apporiented.hermesftp.server.impl.ServerRFC2428Test.java

/**
 * Test case: Extended passive port.//from   w w  w  .  ja v a2s.c  om
 */
@Test
public void testExtendedPassivePort() {
    String str;
    try {
        str = getClient().sendAndReceive("EPSV");
        assertTrue(str.startsWith("229"));
        str = getClient().sendAndReceive("EPSV 1");
        assertTrue(str.startsWith("229"));
        str = getClient().sendAndReceive("EPSV ALL");
        assertTrue(str.startsWith("229"));
        str = getClient().openExtendedPassiveMode();
        assertTrue(str.startsWith("229"));
    } catch (IOException e) {
        log.error(e);
        fail(e.toString());
    }
}

From source file:com.nubits.nubot.launch.toolkit.LaunchUI.java

private void start() {

    local_path = FilesystemUtils.getBotAbsolutePath();

    String configPath = askUser(); //Ask user for path; returns "" if nothing selected

    command = EXECUTE_JAR + " " + JAR_FILE + " ";
    if (!configPath.equals("")) {//User indicated a file
        command += CFG_PREFIX + configPath + " ";
    }/*from  w w  w .  j a  v a2s  .co  m*/

    command += ARGS;

    Runtime rt = Runtime.getRuntime();
    try {
        if (SystemUtils.IS_OS_WINDOWS) {
            //for windows the launch command requires a different syntax
            command = "cmd /c " + command;
        }

        System.out.println("Launching UI from CLI : $ " + command);
        Process pr = rt.exec(command); //Run

    } catch (IOException e) {
        LOG.error(e.toString());
    }

    System.exit(0);
}