Example usage for java.io UncheckedIOException UncheckedIOException

List of usage examples for java.io UncheckedIOException UncheckedIOException

Introduction

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

Prototype

public UncheckedIOException(String message, IOException cause) 

Source Link

Document

Constructs an instance of this class.

Usage

From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java

/** Gets the pipelines definition XML as an JSON string */
public String getPipelineDefinitionAsJson() {
    try (InputStream inputStream = propertiesUtil.getPipelineDefinitions().getInputStream()) {
        String pipelinesXmlString = IOUtils.toString(inputStream);
        JSONObject xmlJSONObj = XML.toJSONObject(pipelinesXmlString);
        return xmlJSONObj.toString();
    } catch (IOException ex) {
        throw new UncheckedIOException("Could not read pipeline definition file", ex);
    }/*from   w ww  .j a  v a2s  .c  om*/
}

From source file:org.trellisldp.http.impl.HttpUtils.java

/**
 * Close an input stream in an async chain.
 * @param input the input stream//from   w w  w .  j a  v  a2  s .  c  o  m
 * @return a bifunction that closes the stream
 */
public static BiConsumer<Object, Throwable> closeInputStreamAsync(final InputStream input) {
    return (val, err) -> {
        try {
            input.close();
        } catch (final IOException ex) {
            throw new UncheckedIOException("Error closing input stream", ex);
        }
    };
}

From source file:org.mitre.mpf.wfm.service.component.StartupComponentRegistrationServiceImpl.java

private static List<Path> listDirContent(Path dir) {
    if (!Files.isDirectory(dir)) {
        return Collections.emptyList();
    }//from   w w  w.  j  a  v a  2 s  . c  o  m
    try (Stream<Path> dirChildren = Files.list(dir)) {
        return dirChildren.collect(toList());
    } catch (IOException e) {
        throw new UncheckedIOException("Failed to list contents of: " + dir, e);
    }
}

From source file:org.mitre.mpf.wfm.service.PipelineServiceImpl.java

/** Gets the pipelines definition XML as an JSON string */
@Override/*from  w  w  w.ja  v  a 2 s  . c o  m*/
public String getPipelineDefinitionAsJson() {
    try (InputStream inputStream = propertiesUtil.getPipelineDefinitions().getInputStream()) {
        String pipelinesXmlString = IOUtils.toString(inputStream);
        JSONObject xmlJSONObj = XML.toJSONObject(pipelinesXmlString);
        return xmlJSONObj.toString();
    } catch (IOException ex) {
        throw new UncheckedIOException("Could not read pipeline definition file", ex);
    }
}