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.opendatakit.briefcase.reused.UncheckedFiles.java

public static void close(OutputStreamWriter osw) {
    try {//w  w w  . j  a  v a2s .  com
        osw.flush();
        osw.close();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

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

public static String encodeInternally(String s) {
    try {/*from w  w w.j  a  v  a 2  s. c o  m*/
        return URLEncoder.encode(s, "UTF8");
    } catch (UnsupportedEncodingException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.example.bot.spring.KitchenSinkController.java

private void reply(@NonNull String replyToken, @NonNull List<Message> messages) {
    try {// w  ww  .  j  a  va  2 s .  c o  m
        Response<BotApiResponse> apiResponse = lineMessagingService
                .replyMessage(new ReplyMessage(replyToken, messages)).execute();
        log.info("Sent messages: {}", apiResponse);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

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

public static Stream<Path> list(Path dir) {
    try {/*from w  ww.j  a  v  a2  s. com*/
        return Files.list(dir);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

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

public static String decodeInternally(String encoded) {
    try {/*from ww w  . j a v a2 s  . c o m*/
        return URLDecoder.decode(encoded, "UTF8");
    } catch (UnsupportedEncodingException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:am.ik.categolj3.api.git.GitStore.java

Git getGitDirectory() {
    try {/*  w w  w.  jav a  2s  .  co m*/
        if (gitProperties.getBaseDir().exists()) {
            if (gitProperties.isInit()) {
                FileSystemUtils.deleteRecursively(gitProperties.getBaseDir());
            } else {
                return Git.open(gitProperties.getBaseDir());
            }
        }
        CloneCommand clone = Git.cloneRepository().setURI(gitProperties.getUri())
                .setDirectory(gitProperties.getBaseDir());
        gitProperties.credentialsProvider().ifPresent(clone::setCredentialsProvider);
        return clone.call();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    } catch (GitAPIException e) {
        throw new IllegalStateException(e);
    }
}

From source file:org.geowebcache.storage.BlobStore.java

/**
 * If the given layer is cached, remove 
 * @param layer/* w w w .j ava2  s.  co m*/
 * @throws StorageException
 */
public default boolean purgeOrphans(TileLayer layer) throws StorageException {
    // TODO maybe do purging based on gridset and format
    try {
        final List<ParameterFilter> parameterFilters = layer.getParameterFilters();

        // Given known parameter mapping, figures out if the parameters need to be purged
        final Function<Map<String, String>, Boolean> parametersNeedPurge = parameters -> {
            return parameters.size() != parameterFilters.size() || // Should have the same number of parameters as the layer has filters
            parameterFilters.stream().allMatch(pfilter -> { // Do all the parameter filters on the layer consider their parameter legal
                final String key = pfilter.getKey();
                final String value = parameters.get(key);
                if (Objects.isNull(value)) {
                    return true; // No parameter for this filter so purge
                }
                return !pfilter.isFilteredValue(value); // purge if it's not a filtered value
            });
        };

        return getParametersMapping(layer.getName()).entrySet().stream().filter(parameterMapping -> {
            return parameterMapping.getValue().map(parametersNeedPurge).orElse(true); // Don't have the original values so purge
        }).map(Map.Entry::getKey) // The parameter id
                .map(id -> {
                    try {
                        return this.deleteByParametersId(layer.getName(), id);
                    } catch (StorageException e) {
                        throw new UncheckedIOException(e);
                    }
                }).reduce((x, y) -> x || y) // OR results without short circuiting
                .orElse(false);
    } catch (UncheckedIOException ex) {
        if (ex.getCause() instanceof StorageException) {
            throw (StorageException) ex.getCause();
        } else {
            throw ex;
        }
    }
}

From source file:net.staticsnow.nexus.repository.apt.internal.proxy.AptProxyFacet.java

private static <T, R> Function<T, R> ioCheck(IOExceptionFunction<T, R> func) {
    return t -> {
        try {/*from ww w.j  a v  a2s.  com*/
            return func.apply(t);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    };
}

From source file:edu.umd.umiacs.clip.tools.io.AllFiles.java

public static Path write(Path path, Stream<?> lines, Charset cs, OpenOption... options) {
    if (options.length == 0) {
        options = new OpenOption[] { CREATE_NEW };
    }/*from w ww.  j a  v  a 2  s. co  m*/
    Objects.requireNonNull(lines);
    CharsetEncoder encoder = cs.newEncoder();
    try {
        OutputStream out = newOutputStream(path, options);
        if (path.toString().endsWith(".gz")) {
            out = new GZIPOutputStream(out);
        } else if (path.toString().endsWith(".bz2")) {
            out = new BZip2CompressorOutputStream(out);
        }
        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, encoder), BUFFER_SIZE)) {
            lines.forEach(line -> {
                try {
                    writer.append(line.toString());
                    writer.newLine();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return path;
}

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

public static Stream<String> lines(Path path) {
    try {/*from  ww w .  j  a v a2  s  .c om*/
        return Files.lines(path, UTF_8);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}