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:org.cryptomator.frontend.webdav.servlet.DavFolder.java

private void addMemberFolder(DavFolder memberFolder) {
    try {//from   ww w  .jav a 2  s  .c o m
        Files.createDirectory(memberFolder.path);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

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

private Response<String> uncheckedExecute(Request<?> request, Executor executor) {
    org.apache.http.client.fluent.Request commonsRequest = getCommonsRequest(request);
    commonsRequest.connectTimeout(10_000);
    commonsRequest.socketTimeout(10_000);
    commonsRequest.addHeader("X-OpenRosa-Version", "1.0");
    request.headers.forEach(pair -> commonsRequest.addHeader(pair.getLeft(), pair.getRight()));
    try {/*from   w w w.  j  av  a  2 s  .c o m*/
        return executor.execute(commonsRequest).handleResponse(res -> {
            if (res.getStatusLine().getStatusCode() >= 500)
                return new Response.ServerError<>(res.getStatusLine().getStatusCode(),
                        res.getStatusLine().getReasonPhrase());
            if (res.getStatusLine().getStatusCode() >= 400)
                return new Response.ClientError<>(res.getStatusLine().getStatusCode(),
                        res.getStatusLine().getReasonPhrase());
            if (res.getStatusLine().getStatusCode() >= 300)
                return new Response.Redirection<>(res.getStatusLine().getStatusCode(),
                        res.getStatusLine().getReasonPhrase());
            return new Response.Success<>(res.getStatusLine().getStatusCode(), readBody(res));
        });
    } catch (HttpHostConnectException e) {
        throw new HttpException("Connection refused");
    } catch (SocketTimeoutException | ConnectTimeoutException e) {
        throw new HttpException("The connection has timed out");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

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

public static Path createTempDirectory(Path dir, String prefix, FileAttribute<?>... attrs) {
    try {//from  ww  w .j a v a2s.c  o m
        return Files.createTempDirectory(dir, prefix, attrs);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:objective.taskboard.utils.ZipUtils.java

public static void zip(Path input, Path output) {
    try (Stream<Path> stream = walk(input)) {
        File outputParent = output.toFile().getParentFile();
        if (outputParent != null && !outputParent.exists())
            createDirectories(outputParent.toPath());
        try (ZipOutputStream zipOutputStream = new ZipOutputStream(Files.newOutputStream(output))) {
            stream.filter(path -> path.toFile().isFile()).forEach(path -> {
                try {
                    Path inputDirectory = input.toFile().isDirectory() ? input : input.getParent();
                    ZipEntry entry = new ZipEntry(inputDirectory.relativize(path).toString());
                    zipOutputStream.putNextEntry(entry);
                    copy(path, zipOutputStream);
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }//from  ww  w .  j  a va  2 s.co m
            });
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:nl.knaw.huc.di.tag.tagml.importer.ImportDataTAGMLTest.java

private void processTAGMLFile(String basename) throws TAGMLSyntaxError {
    store.runInTransaction(() -> {/*from   w ww .  j  a va  2  s. com*/
        try {
            InputStream input = getInputStream(basename);
            List<String> lines = IOUtils.readLines(input, Charset.defaultCharset());
            LOG.info("\nTAGML:\n{}\n", String.join("\n", lines));

            input = getInputStream(basename);
            printTokens(input);

            input = getInputStream(basename);
            LOG.info("testing data/tagml/{}.tagml", basename);
            LOG.info("importTAGML\n");
            TAGDocument document = new TAGMLImporter(store).importTAGML(input);
            logDocumentGraph(document, "");
            //        generateLaTeX(basename, document);
        } catch (IOException e) {
            e.printStackTrace();
            throw new UncheckedIOException(e);
        }
    });
}

From source file:com.joyent.manta.client.crypto.MantaEncryptedObjectInputStreamTest.java

public MantaEncryptedObjectInputStreamTest() {
    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    this.testURL = classLoader.getResource("test-data/chaucer.txt");

    try {//  ww w.  j  a v  a2s.c  o m
        testFile = Paths.get(testURL.toURI());
    } catch (URISyntaxException e) {
        throw new AssertionError(e);
    }

    this.plaintextSize = (int) testFile.toFile().length();

    try (InputStream in = this.testURL.openStream()) {
        this.plaintextBytes = IOUtils.readFully(in, plaintextSize);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:org.cryptomator.frontend.webdav.jackrabbitservlet.DavFolder.java

private void addMemberFile(DavFile memberFile, InputStream inputStream) {
    try (ReadableByteChannel src = Channels.newChannel(inputStream);
            WritableFile dst = node.file(memberFile.getDisplayName()).openWritable()) {
        dst.truncate();//from  w  ww. j a v  a 2s.c  o m
        ByteStreams.copy(src, dst);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

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

public GfshExecution execute(GfshScript gfshScript) {
    GfshExecution gfshExecution;/*from   w  ww  .  j  a  v  a  2 s.c o m*/
    try {
        File workingDir = new File(temporaryFolder.getRoot(), gfshScript.getName());
        workingDir.mkdirs();
        Process process = toProcessBuilder(gfshScript, gfsh, workingDir).start();
        gfshExecution = new GfshExecution(process, workingDir);
        gfshExecutions.add(gfshExecution);
        gfshScript.awaitIfNecessary(process);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }

    return gfshExecution;
}

From source file:org.sonatype.nexus.repository.proxy.ProxyHandlerTest.java

@Test
public void testUncheckedIOExceptionReturns502Response() throws Exception {
    when(request.getAction()).thenReturn(HttpMethods.GET);
    doThrow(new UncheckedIOException(new IOException("message"))).when(proxyFacet).get(context);
    assertStatusCode(underTest.handle(context), HttpStatus.BAD_GATEWAY);
}

From source file:de.siegmar.securetransfer.component.Cryptor.java

private byte[] initSalt(final Path baseDir) {
    final Path saltFile = baseDir.resolve("salt");
    try {/*from   ww w .  j a va 2 s  . c o m*/
        if (Files.exists(saltFile)) {
            return Files.readAllBytes(saltFile);
        }

        final byte[] newSalt = newRandom(SALT_SIZE);
        Files.write(saltFile, newSalt, StandardOpenOption.CREATE_NEW);

        LOG.info("Initialized instance salt at {}", saltFile);
        return newSalt;
    } catch (final IOException e) {
        throw new UncheckedIOException(e);
    }
}