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.apache.james.queue.rabbitmq.view.cassandra.EnqueuedMailsDaoUtil.java

private static AttributeValue<?> fromByteBuffer(ByteBuffer byteBuffer) {
    try {//from   w  w w  . j  av a2 s . c  om
        return AttributeValue.fromJsonString(StandardCharsets.UTF_8.decode(byteBuffer).toString());
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.github.blindpirate.gogradle.crossplatform.DefaultGoBinaryManager.java

private void fetchNewestStableVersion() {
    try {/* w  w w  . j  av  a 2 s.c o m*/
        String newestStableVersion = httpUtils.get(NEWEST_VERSION_URL).trim();
        fetchSpecifiedVersion(newestStableVersion);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:uk.trainwatch.osgb.codepoint.util.CodePointImport.java

private void importer(Connection con, Path path) throws SQLException {
    LOG.log(Level.INFO, () -> "Importing " + path);

    try {// w w w.  j a  v a 2 s .  c  o  m
        try (CSVParser parser = new CSVParser(new FileReader(path.toFile()), CSVFormat.DEFAULT)) {
            List<CSVRecord> records = parser.getRecords();

            // Do the import in one massive transaction
            con.setAutoCommit(false);

            try (PreparedStatement ps = con.prepareStatement(CP_SQL)) {
                records.stream()
                        .map(r -> new PostCode(r.get(0), Integer.parseInt(r.get(1)), Integer.parseInt(r.get(2)),
                                Integer.parseInt(r.get(3)), r.get(4), r.get(5), r.get(6), r.get(7), r.get(8),
                                r.get(9)))
                        .forEach(SQLConsumer.guard(pc -> {
                            SQL.executeUpdate(ps, pc.getPostCode(), pc.getPqi(), pc.getEastings(),
                                    pc.getNorthings(), codeLookup.getOrDefault(pc.getCountry(), 0),
                                    codeLookup.getOrDefault(pc.getCounty(), 0),
                                    codeLookup.getOrDefault(pc.getDistrict(), 0),
                                    codeLookup.getOrDefault(pc.getWard(), 0),
                                    nhsLookup.getOrDefault(pc.getNhsRegion(), 0),
                                    nhsLookup.getOrDefault(pc.getNhs(), 0));
                        }));
            }

            con.commit();

            int parseCount = records.size();
            lineCount += parseCount;
            LOG.log(Level.INFO, () -> "Parsed " + parseCount);
        }

    } catch (IOException ex) {
        con.rollback();
        LOG.log(Level.SEVERE, null, ex);
        throw new UncheckedIOException(ex);
    } catch (UncheckedSQLException ex) {
        con.rollback();
        LOG.log(Level.SEVERE, null, ex);
        throw ex.getCause();
    } catch (Exception ex) {
        con.rollback();
        LOG.log(Level.SEVERE, null, ex);
        throw new RuntimeException(ex);
    }
}

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

public static void walkFileTreeSafely(Path path, FileVisitor<? super Path> visitor) {
    try {//w w w. j  a  va 2s  .  c  o m
        Files.walkFileTree(path, EnumSet.noneOf(FileVisitOption.class), MAX_DFS_DEPTH, visitor);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:org.apache.geode.distributed.LauncherIntegrationTestCase.java

public String getJavaPath() {
    try {//from ww  w .ja v a  2s .  c  o m
        return new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:io.divolte.server.filesinks.hdfs.FileFlusherLocalHdfsTest.java

private DataFileReader<Record> readAvroFile(final Schema schema, final File file) {
    final DatumReader<Record> dr = new GenericDatumReader<>(schema);
    try {/*ww w . j  av a2s .  c  o m*/
        return new DataFileReader<>(file, dr);
    } catch (final IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.joyent.manta.client.multipart.ServerSideMultipartManager.java

@Override
public Stream<MantaMultipartUpload> listInProgress() throws IOException {
    final String uploadsPath = uploadsPath();

    Stream<MantaMultipartUpload> stream = mantaClient.listObjects(uploadsPath).map(mantaObject -> {
        try {/*from w  ww.ja v  a  2  s. c  om*/
            return mantaClient.listObjects(mantaObject.getPath()).map(item -> {
                final String objectName = FilenameUtils.getName(item.getPath());
                final UUID id = UUID.fromString(objectName);

                // We don't know the final object name. The server will implement
                // this as a feature in the future.

                return new ServerSideMultipartUpload(id, null, uuidPrefixedPath(id));
            }).collect(Collectors.toSet());
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }).flatMap(Collection::stream);

    danglingStreams.add(stream);

    return stream;
}

From source file:org.springframework.cloud.function.deployer.FunctionCreatorConfiguration.java

private Function<String, Stream<URL>> toResourceURL(DelegatingResourceLoader resourceLoader) {
    return l -> {
        if (l.equals("app:classpath")) {
            return Stream.of(urls());
        }/*  www.  j  a va 2 s .  c  o  m*/
        try {
            return Stream.of(resourceLoader.getResource(l).getFile().toURI().toURL());
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    };
}

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

@Override
public void create() {
    parent.create();//  w w  w . j a  v a  2s  .  c om
    final boolean newDirIdGiven = directoryId.compareAndSet(null, UUID.randomUUID().toString());
    final File dirFile = forceGetPhysicalFile();
    final Folder dir = forceGetPhysicalFolder();
    if (dirFile.exists() && dir.exists()) {
        return;
    } else if (!newDirIdGiven) {
        throw new IllegalStateException(
                "Newly created folder, that didn't exist before, already had an directoryId.");
    }
    if (parent.file(name).exists()) {
        throw new UncheckedIOException(new FileAlreadyExistsException(parent.file(name).toString()));
    }
    FileContents.UTF_8.writeContents(dirFile, directoryId.get());
    dir.create();
}

From source file:org.wildfly.swarm.proc.Monitor.java

private static boolean isSameFile(Path path1, Path path2) {
    try {//from   w w w . j ava  2s  .  c o  m
        return Files.isSameFile(path1, path2);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}