Example usage for java.io IOException getMessage

List of usage examples for java.io IOException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:net.padlocksoftware.padlock.licensevalidator.Main.java

private static void parseKeyPairFile(String fileName) {
    try {/*  w  w  w. java 2  s . c o  m*/
        pair = KeyManager.importKeyPair(new File(fileName));
    } catch (IOException ex) {
        System.err.println("Error reading key file: " + ex.getMessage());
        System.exit(1);
    }
}

From source file:com.canoo.webtest.boundary.StreamBoundary.java

public static byte[] tryGetBytes(final Context context, final Step step) {
    try {//from   w  ww.ja  va  2  s  .co m
        return IOUtils.toByteArray(context.getCurrentResponse().getWebResponse().getContentAsStream());
    } catch (IOException e) {
        throw new StepExecutionException("Error processing content: " + e.getMessage(), step);
    }
}

From source file:de.xirp.managers.PrintManager.java

/**
 * Prints the corresponding report pdf for the given
 * {@link de.xirp.report.ReportDescriptor}
 * /*  w w w  .ja va 2 s.c o  m*/
 * @param rd
 *            The descriptor to print the corresponding pdf for.
 */
public static void print(final ReportDescriptor rd) {
    File tmp = new File(Constants.TMP_DIR, rd.getFileName());
    DeleteManager.deleteOnShutdown(tmp);
    try {
        FileUtils.writeByteArrayToFile(tmp, rd.getPdfData());
        print(tmp);
    } catch (IOException e) {
        logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$
    }
}

From source file:net.padlocksoftware.padlock.licensevalidator.Main.java

private static void parseLicenseFile(String fileName) {
    try {//from ww  w .j av  a2s. c  om
        license = LicenseIO.importLicense(new File(fileName));
    } catch (IOException ex) {
        System.err.println("Error reading license: " + ex.getMessage());
        System.exit(1);
    } catch (ImportException ex) {
        System.err.println("Error parsing license data: " + ex.getMessage());
        System.exit(1);
    }
}

From source file:com.hybridbpm.ui.component.chart.util.DiagrammeUtil.java

public static byte[] readFromSource(String path) {
    InputStream streamSource = DiagrammeUtil.class.getResourceAsStream(path);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] buffer = new byte[1024];
    int length = 0;
    try {/*w  w  w . j ava 2 s.c om*/
        while ((length = streamSource.read(buffer)) != -1) {
            baos.write(buffer, 0, length);
        }
    } catch (IOException ex) {
        Logger.getLogger(DiagrammeUtil.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
    }
    return baos.toByteArray();
}

From source file:net.jcreate.e3.table.skin.processor.VelocityHelper.java

public static Properties getDefaultProperties() throws InitVelocityEngineException {
    InputStream is = VelocityHelper.class.getResourceAsStream("Velocity.properties");
    Properties props = new Properties();
    try {/*ww  w.  jav  a2  s.  c o  m*/
        props.load(is);
    } catch (IOException e) {
        e.printStackTrace();
        final String MSG = "!" + e.getMessage();
        if (log.isErrorEnabled()) {
            log.error("!" + e.getMessage());
        }
        throw new InitVelocityEngineException(MSG, e);
    }
    return props;
}

From source file:lh.api.showcase.server.util.HttpQueryUtils.java

public static String executeQuery(URI uri, ApiAuth apiAuth, HasProxySettings proxySetting,
        HttpClientFactory httpClientFactory, final int maxRetries) throws HttpErrorResponseException {

    //logger.info("uri: " + uri.toString());

    AtomicInteger tryCounter = new AtomicInteger(0);
    while (true) {

        CloseableHttpClient httpclient = httpClientFactory.getHttpClient(proxySetting);
        HttpGet httpGet = new HttpGet(uri);
        httpGet.addHeader("Authorization", apiAuth.getAuthHeader());
        httpGet.addHeader("Accept", "application/json");

        //logger.info("auth: " + apiAuth.getAuthHeader()) ;
        //logger.info("query: " + httpGet.toString());

        CloseableHttpResponse response = null;
        try {/*from  w w  w .j  a  va  2  s  .c o  m*/
            response = httpclient.execute(httpGet);
            StatusLine status = response.getStatusLine();
            BufferedHttpEntity entity = new BufferedHttpEntity(response.getEntity());
            String json = IOUtils.toString(entity.getContent(), "UTF8");
            EntityUtils.consume(entity);
            //logger.info("response: " + json);

            // check for errors
            if (status != null && status.getStatusCode() > 299) {
                if (status.getStatusCode() == 401) {
                    // token has probably expired
                    logger.info("Authentication Error. Token will be refreshed");
                    if (tryCounter.getAndIncrement() < maxRetries) {
                        if (apiAuth.updateAccessToken()) {
                            logger.info("Token successfully refreshed");
                            // we retry with the new token
                            logger.info("Retry number " + tryCounter.get());
                            continue;
                        }
                    }
                }
                throw new HttpErrorResponseException(status.getStatusCode(), status.getReasonPhrase(), json);
            }
            return json;
        } catch (IOException e) {
            logger.severe(e.getMessage());
            break;
        } finally {
            try {
                if (response != null) {
                    response.close();
                }
            } catch (IOException e) {
                logger.log(Level.SEVERE, e.getMessage());
            }
        }
    }
    return null;
}

From source file:mitm.common.util.ProcessUtils.java

/**
 * Helper method that executes the given cmd and returns the output. The process will be destroyed 
 * if the process takes longer to execute than the timeout.  
 *//*  ww w .j  a  va 2  s  .  co  m*/
public static String executeCommand(List<String> cmd, long timeout, long maxOutputLength, InputStream input)
        throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    SizeLimitedOutputStream slos = new SizeLimitedOutputStream(bos, maxOutputLength);

    try {
        executeCommand(cmd, timeout, input, slos);

        return MiscStringUtils.toAsciiString(bos.toByteArray());
    } catch (IOException e) {
        throw new IOException(e.getMessage() + ". Output: " + MiscStringUtils.toAsciiString(bos.toByteArray()),
                e);
    }
}

From source file:Main.java

public static Node readXML(URI uri) {
    try {/*from  ww  w . j a v a  2s.co  m*/
        DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = builderFactory.newDocumentBuilder();

        Document doc = builder.parse(uri.toString());
        return doc.getDocumentElement();
    } catch (SAXException saxEx) {
        throw new IllegalArgumentException("readXML() Caught SAXException: ", saxEx);
    } catch (IOException ioEx) {
        throw new IllegalArgumentException("readXML() Caught IOException: " + ioEx.getMessage(), ioEx);
    } catch (ParserConfigurationException parsEx) {
        throw new IllegalArgumentException("readXML() Caught ParserConfigurationException: ", parsEx);
    } // try - catch
}

From source file:CFDI_Verification.CFDI_Verification.java

public static String test_Connection(String directory) {

    String server = "192.1.1.64";
    String user = "ftpuser";
    String pass = "Oracle123";
    String result = "No Connected!";

    FTPClient ftpClient = new FTPClient();

    try {/*www  .j ava2  s .  co  m*/
        ftpClient.connect(server);
        ftpClient.login(user, pass);
        ftpClient.enterLocalPassiveMode();
        ftpClient.changeWorkingDirectory(directory);

        if (ftpClient.isConnected() == true) {
            result = "Connected to " + ftpClient.printWorkingDirectory();
        }

        ftpClient.logout();
        ftpClient.disconnect();

    } catch (IOException ex) {
        System.out.println("Ooops! Error en conexin." + ex.getMessage());
    } finally {
        return result;
    }
}