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(IOException cause) 

Source Link

Document

Constructs an instance of this class.

Usage

From source file:com.github.blindpirate.gogradle.util.IOUtils.java

public static void copyDirectory(File src, File dest) {
    try {//from   w  w w. j a  va2 s. co  m
        org.apache.commons.io.FileUtils.copyDirectory(src, dest);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:org.apache.geode.test.junit.rules.GfshShellConnectionRule.java

public GfshShellConnectionRule() {
    try {/*from ww  w  . ja  v  a 2s . co  m*/
        temporaryFolder.create();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:onl.area51.httpd.service.HttpService.java

@PostConstruct
void start() {//from   ww  w  .  j a  va2 s . c  om
    httpdConfig = configurationService.getConfiguration("httpd");

    port = httpdConfig.getInt("port", 8080);
    serverInfo = httpdConfig.getString("serverInfo", "Area51/1.1");

    LOG.log(Level.INFO, () -> "Creating http server " + serverInfo + " on port " + port);

    HttpServerBuilder serverBuilder = HttpServerBuilder.builder()
            // HTTP Server config
            .setSocketConfig(SocketConfig.custom().setSoTimeout(httpdConfig.getInt("socket.soTimeout", 15000))
                    .setTcpNoDelay(httpdConfig.getBoolean("socket.tcpNoDelay", true)).build())
            .setListenerPort(port).setServerInfo(serverInfo).setSslContext(null)
            .setExceptionLogger(ex -> LOG.log(Level.SEVERE, null, ex))
            .shutdown(httpdConfig.getLong("shutdown.time", 5L),
                    httpdConfig.getEnum("shutdown.unit", TimeUnit.class, TimeUnit.SECONDS));

    // Default global action is to serve resources
    Actions.registerClassResourceHandler(serverBuilder, HttpService.class);

    serverBuilder.notify(CDI.current().getBeanManager()::fireEvent);

    // Add global error handlers. As these are at the end, earlier ones take precedence
    Actions.registerErrorHandlers(serverBuilder);

    server = serverBuilder.build();

    LOG.log(Level.INFO, () -> "Starting http server " + serverInfo + " on port " + port);

    try {
        server.start();
    } catch (IOException ex) {
        throw new UncheckedIOException(ex);
    }

    LOG.log(Level.INFO, () -> "Started http server " + serverInfo + " on port " + port);
}

From source file:org.cryptomator.filesystem.crypto.CryptoFolder.java

Folder forceGetPhysicalFolder() {
    return physicalFolder().orElseThrow(() -> {
        return new UncheckedIOException(new FileNotFoundException(toString()));
    });/*from   w w  w .  ja  v a2 s.c om*/
}

From source file:org.opendatakit.briefcase.reused.UncheckedFiles.java

public static Stream<Path> walk(Path path, FileVisitOption... options) {
    try {/*  w w w  .  j a  v a  2  s .c o m*/
        return Files.walk(path, options);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.thoughtworks.go.server.dashboard.AbstractDashboardGroup.java

protected String digest(String permissionsSegment) {
    try {/*  w  w  w.  ja va2  s  .  c  om*/
        MessageDigest digest = DigestUtils.getSha256Digest();
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
                new DigestOutputStream(new NullOutputStream(), digest));
        outputStreamWriter.write(getClass().getSimpleName());
        outputStreamWriter.write("$");
        outputStreamWriter.write(name());
        outputStreamWriter.write("/");
        outputStreamWriter.write(permissionsSegment);
        outputStreamWriter.write("[");

        for (GoDashboardPipeline pipeline : allPipelines()) {
            outputStreamWriter.write(pipeline.cacheSegment());
            outputStreamWriter.write(",");
        }

        outputStreamWriter.write("]");
        outputStreamWriter.flush();

        return Hex.encodeHexString(digest.digest());
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:org.haiku.haikudepotserver.config.AppConfig.java

@Bean
public Properties jawrConfigProperties(@Value("${jawr.debug.on:false}") Boolean debug) {
    Properties properties = new Properties();

    try (InputStream inputStream = new ClassPathResource("jawr.properties").getInputStream()) {
        properties.load(inputStream);/*from ww  w .  j a va2s  .  c  o  m*/
    } catch (IOException ioe) {
        throw new UncheckedIOException(ioe);
    }

    properties.setProperty("jawr.debug.on", Boolean.toString(debug));
    properties.setProperty("jawr.factory.use.orphans.mapper", Boolean.toString(false));

    return properties;
}

From source file:com.discovery.darchrow.io.FileUtil.java

/**
 * ? {@code byte[] bytes}.//from  ww w  .j  a  v a  2s  .  c  o m
 *
 * @param file
 *            file
 * @return {@link java.io.ByteArrayOutputStream#toByteArray()}
 * @see com.baozun.nebulaplus.io.FileUtil#getFileInputStream(File)
 * @see java.io.ByteArrayOutputStream#toByteArray()
 */
public static final byte[] toByteArray(File file) {
    InputStream inputStream = getFileInputStream(file);

    //Creates a BufferedInputStream and saves its argument, the input stream in, for later use. 
    //An internal buffer array is created and stored in buf.
    BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);

    //Creates a new byte array output stream. 
    //The buffer capacity is initially 32 bytes, though its size increases if necessary. 
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

    try {
        byte[] bytes = new byte[IOConstants.DEFAULT_BUFFER_LENGTH];
        int j;
        while ((j = bufferedInputStream.read(bytes)) != -1) {
            byteArrayOutputStream.write(bytes, 0, j);
        }
        byteArrayOutputStream.flush();

        byte[] byteArray = byteArrayOutputStream.toByteArray();
        return byteArray;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    } finally {
        // ???StreamClose.??Close
        IOUtils.closeQuietly(byteArrayOutputStream);
        IOUtils.closeQuietly(bufferedInputStream);
    }
}

From source file:org.opendatakit.briefcase.reused.http.CommonsHttp.java

private static <T> T uncheckedHandleEntity(AbstractResponseHandler<T> handler, HttpEntity entity) {
    try {//from  w  w  w  .  j  a  v a2  s .  c  o m
        return handler.handleEntity(entity);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:io.werval.modules.json.JacksonJSON.java

@Override
public <T> T fromJSON(Class<T> type, byte[] json) {
    try {/*from   w  w  w .j a va2  s . co  m*/
        return mapper.readValue(json, type);
    } catch (JsonProcessingException ex) {
        throw new JsonPluginException(ex);
    } catch (IOException ex) {
        throw new UncheckedIOException(ex);
    }
}