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:Main.java

public static Document parseXmlStringToDocument(String xmlString) {

    if (xmlString == null)
        return null;

    Document document;/*from  w ww  .  j av  a  2s . co m*/

    try {

        InputSource source = new InputSource(new StringReader(xmlString));

        document = documentBuilder.parse(source);
    } catch (IOException ex) {

        throw new RuntimeException("Failed to parse input stream due to I/O errors: " + ex.getMessage(), ex);
    } catch (SAXException ex) {

        throw new RuntimeException("Failed to parse input stream due to SAX errors: " + ex.getMessage(), ex);
    }

    return document;
}

From source file:org.linkedeconomy.espa.service.impl.rdf.SubprojectsSellersImpl.java

public static void subprojectsSellers() {

    //services for each table
    ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
    SubProjectSellersService sub = (SubProjectSellersService) ctx.getBean("subProjectSellersServiceImpl");

    List<SubProjectSellers> subProjectSeller = sub.getSubProjectSellers();

    //--------------RDF Model--------------//
    Model model = ModelFactory.createDefaultModel();
    Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
    InfModel infModel = ModelFactory.createInfModel(reasoner, model);

    model.setNsPrefix("elod", OntologySpecification.elodPrefix);
    model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix);

    for (SubProjectSellers subProjectSeller1 : subProjectSeller) {
        Resource instanceSeller = infModel.createResource(
                OntologySpecification.instancePrefix + "Organization/" + subProjectSeller1.getSellerId());
        Resource instanceSubProject = infModel.createResource(OntologySpecification.instancePrefix
                + "Subproject/" + subProjectSeller1.getOps() + "/" + subProjectSeller1.getSubProjectId());
        infModel.add(instanceSeller, RDF.type, OntologySpecification.organizationResource);
        infModel.add(instanceSeller, RDF.type, OntologySpecification.businessResource);
        infModel.add(instanceSubProject, RDF.type, OntologySpecification.subProjectResource);
        instanceSubProject.addProperty(OntologySpecification.seller, instanceSeller);
    }//from   ww  w.java2  s  .  c  o  m

    try {
        FileOutputStream fout = new FileOutputStream(
                "/Users/giovaf/Documents/yds_pilot1/espa_tests/22-02-2016_ouput/subProjectSellersEspa.rdf");
        model.write(fout);
    } catch (IOException e) {
        System.out.println("Exception caught" + e.getMessage());
    }
}

From source file:org.ow2.chameleon.everest.internals.JSONUtils.java

public static <T> T instantiate(String json, Class<T> clazz) {
    if (MAPPER == null || !mayBeJSON(json)) {
        return null;
    } else {/*from  ww  w. j a  va  2  s  .  c  om*/
        try {
            return MAPPER.readValue(json, clazz);
        } catch (IOException e) {
            System.err.println("Cannot build bean from json string : " + e.getMessage());
            return null;
        }
    }
}

From source file:test.LocationCrawler.java

public static String getLocationCoord(String Address) {
    String jsonString = ProcessLocationRequest(Address);
    String LocationCoord = "";

    if (jsonString.length() > 0) {
        try {//from w w w  . ja v a2s.c  o m
            ObjectMapper m = new ObjectMapper();
            JsonNode rootNode = m.readTree(jsonString);
            for (JsonNode result : rootNode.path("results")) {
                JsonNode LatLongNode = result.path("geometry").path("location");
                LocationCoord = String.format("%s|%s", LatLongNode.path("lat").doubleValue(),
                        LatLongNode.path("lng").doubleValue());
                break;
            }

        } catch (JsonProcessingException jpe) {
            System.out.println(jpe.getMessage());
        } catch (IOException ioe) {
            System.out.println(ioe.getMessage());
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            return LocationCoord;
        }
    } else {
        return LocationCoord;
    }
}

From source file:org.mobile.mpos.util.HttpClientHelper.java

private static void close(CloseableHttpClient httpClient) {
    try {//www . j a  v  a2s .c om
        if (httpClient != null) {
            httpClient.close();
        }
    } catch (IOException e) {
        log.error("close httpClient IOException " + e.getMessage());
    }
}

From source file:com.netsteadfast.greenstep.util.DynamicHqlUtils.java

public static DynamicHql loadResource(String resource) throws Exception {
    DynamicHql dynamicHql = resourceDataMap.get(resource);
    if (dynamicHql == null) {
        InputStream in = null;/*from ww  w  .  jav  a2 s  .co  m*/
        try {
            in = DynamicHqlUtils.class.getResourceAsStream("/dynamichql/" + resource);
            byte[] xmlBytes = IOUtils.toByteArray(in);
            JAXBContext jaxbContext = JAXBContext.newInstance(DynamicHql.class);
            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            dynamicHql = (DynamicHql) jaxbUnmarshaller.unmarshal(new ByteArrayInputStream(xmlBytes));
            resourceDataMap.put(resource, dynamicHql);
        } catch (IOException e) {
            logger.error(e.getMessage().toString());
            throw e;
        } finally {
            if (in != null) {
                IOUtils.closeQuietly(in);
            }
            in = null;
        }
    }
    return dynamicHql;
}

From source file:be.vlaanderen.sesam.monitor.internal.util.BodyUtils.java

public static String getMd5Sum(File f) {
    FileInputStream fis = null;//from   www .  j  a v  a 2s  . c  o  m
    try {
        fis = new FileInputStream(f);
        String res = DigestUtils.md5Hex(fis);
        log.debug("Hashed file: {} -- {}", f.getName(), res);
        return res;
    } catch (IOException e) {
        log.warn("Failed calculating MD5sum. " + e.getMessage());
        return null;
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException e) {
            }
        }
    }
}

From source file:att.jaxrs.util.Marshal.java

public static <T> T unmarshal(Class<T> xmlType, HttpResponse httpResponse) throws JAXBException {
    String namespace = "";
    try {/*from   w  w  w. j a v a  2s  .  co m*/
        namespace = Util.getStringFromInputStream(httpResponse.getEntity().getContent());
        System.out.println(namespace);
    } catch (IOException e) {
        System.out.println(e.getMessage());
    }

    System.out.println(namespace);
    namespace = namespace.replaceAll(Constants.DATA_SERVICE_XMLNS, "");
    System.out.println(namespace);
    InputStream stream = Util.getInputStreamFromString(namespace);
    JAXBContext jaxbContext = JAXBContext.newInstance(xmlType);
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

    return (T) unmarshaller.unmarshal(stream);
}

From source file:com.arrggh.eve.api.sde.StaticDataExportImporter.java

private static <T> T process(InputStream inputStream, TypeReference<T> typeReference) throws IOException {
    String yaml = IOUtils.toString(inputStream, "utf-8");
    try {/*from w  w w. jav  a2 s. co m*/
        return mapper.readValue(yaml, typeReference);
    } catch (IOException e) {
        System.out.println(e.getMessage());
        //            System.out.println(yaml);
        throw e;
    }
}

From source file:net.jcreate.e3.templateEngine.webmacro.WebMacroHelper.java

public static Properties getDefaultProperties() throws InitWebMacroEngineException {
    InputStream is = WebMacroHelper.class.getResourceAsStream("WebMacro.properties");
    Properties props = new Properties();
    try {//  www .j av a 2 s .  co  m
        props.load(is);
    } catch (IOException e) {
        final String MSG = "!" + e.getMessage();
        if (log.isErrorEnabled()) {
            log.error(MSG, e);
        }
        throw new InitWebMacroEngineException(MSG, e);
    }
    return props;
}