List of usage examples for java.io UncheckedIOException UncheckedIOException
public UncheckedIOException(IOException cause)
From source file:org.travis4j.rest.JsonResponse.java
public String getBody() { if (body != null) { return body; }//from w w w . j ava 2 s. c o m if (!isOk()) { // FIXME throw new RuntimeException("No 200 response, was: " + response); } HttpEntity entity = response.getEntity(); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { entity.writeTo(out); body = out.toString(); return body; } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.github.tmyroadctfig.icloud4j.util.ICloudUtils.java
/** * Parses a JSON response from the request. * * @param httpClient the HTTP client./*from w ww. j a v a2 s. c om*/ * @param post the request. * @param responseClass the type of JSON object to parse the values into. * @param <T> the type to parse into. * @return the object. * @throws ICloudException if there was an error returned from the request. */ public static <T> T parseJsonResponse(CloseableHttpClient httpClient, HttpPost post, Class<T> responseClass) { String rawResponseContent = "<no content>"; try (CloseableHttpResponse response = httpClient.execute(post)) { rawResponseContent = new StringResponseHandler().handleResponse(response); try { return fromJson(rawResponseContent, responseClass); } catch (JsonSyntaxException e1) { Map<String, Object> errorMap = fromJson(rawResponseContent, Map.class); System.err.println(rawResponseContent); throw new ICloudException(response, errorMap); } } catch (IOException e) { System.err.println(rawResponseContent); throw new UncheckedIOException(e); } }
From source file:org.travis4j.model.json.LogJsonObject.java
@Override public Stream<String> getBody() { if (cache != null) { return cache.stream(); }// w w w. j a v a 2 s .co m if (body == null) { return null; } try (BufferedReader reader = new BufferedReader(new InputStreamReader(body.getContent()))) { cache = reader.lines().collect(Collectors.toList()); return cache.stream(); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:org.opendatakit.briefcase.reused.UncheckedFiles.java
public static Path write(Path path, Stream<String> lines, OpenOption... options) { try {/*from w ww . j av a2 s .c o m*/ return Files.write(path, (Iterable<String>) lines::iterator, UTF_8, options); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.github.blindpirate.gogradle.util.IOUtils.java
public static void forceMkdir(File directory) { try {//www . j av a2s .com FileUtils.forceMkdir(directory); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.joyent.manta.client.multipart.TestMultipartManager.java
public TestMultipartManager() { try {/*from w ww . j av a 2 s.c o m*/ this.partsDirectory = Files.createTempDirectory("multipart").toFile(); FileUtils.forceDeleteOnExit(partsDirectory); this.destinationDirectory = Files.createTempDirectory("multipart-final").toFile(); FileUtils.forceDeleteOnExit(destinationDirectory); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.github.horrorho.inflatabledonkey.KeyBagManager.java
static Optional<KeyBag> keyBag(HttpClient httpClient, CloudKitty kitty, ProtectionZone mbksync, String uuid) { try {/*from w ww.j a v a 2 s. c om*/ return KeyBagClient.keyBag(httpClient, kitty, mbksync, uuid); } catch (IOException ex) { throw new UncheckedIOException(ex); } }
From source file:edu.umd.umiacs.clip.tools.io.AllFiles.java
public static List<String> readAllLines(Path path) { try {// w w w.j av a 2 s . c om return path.toString().endsWith(".gz") ? GZIPFiles.readAllLines(path) : path.toString().endsWith(".bz2") ? BZIP2Files.readAllLines(path) : _readAllLines(path); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.groupdocs.ui.Utils.java
public static int copyStream(InputStream input, OutputStream output) { try {//w ww. j a v a 2 s. com return IOUtils.copy(input, output); } catch (IOException x) { throw new UncheckedIOException(x); } }
From source file:com.insightml.utils.io.IoUtils.java
public static LineReader lines(final File file) { try {/*from w w w.ja v a2s . c om*/ return new LineReader(inputStream(file)); } catch (final IOException e) { throw new UncheckedIOException(e); } }