List of usage examples for java.io UncheckedIOException UncheckedIOException
public UncheckedIOException(IOException cause)
From source file:edu.jhu.hlt.alnc.ALNCFileConverter.java
/** * Return a {@link Stream} of {@link ALNCArticleBean} objects. This stream should be * closed when processing is complete./*from w w w . j a va2 s .co m*/ * <br> * <br> * This method can throw an unchecked exception. This will * occur when the underlying InputStream does not represent ALNC JSON data. * * @return a {@link Stream} of {@link ALNCArticleBean} objects. * @throws IOException if there is an issue reading the underlying archive. * @throws UncheckedIOException if there is an issue with the conversion. */ public Stream<ALNCArticleBean> stream() throws IOException { return this.br.lines().sequential().map(l -> { try { // unlikely to throw, provided stream is corrent JSON objects. return om.readValue(l, ALNCArticleBean.class); } catch (IOException e) { throw new UncheckedIOException(e); } }); }
From source file:org.opendatakit.briefcase.reused.UncheckedFiles.java
public static Path write(Path path, byte[] contents, OpenOption... options) { try {// w ww . ja va2 s . c om return Files.write(path, contents, options); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.groupdocs.ui.Utils.java
public static int writeToResponse(InputStream input, ServletResponse response) { try {/*from w w w . j a va 2 s .co m*/ return Utils.copyStream(input, response.getOutputStream()); } catch (IOException x) { throw new UncheckedIOException(x); } }
From source file:com.github.blindpirate.gogradle.util.IOUtils.java
public static void forceDelete(final File file) { try {//from w w w. ja v a 2 s .co m if (file != null) { FileUtils.forceDelete(file); } } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:org.everit.json.schema.loader.internal.JSONPointer.java
private static JSONObject executeWith(final SchemaClient client, final String url) { String resp = null;//from w w w . ja v a 2 s .co m BufferedReader buffReader = null; InputStreamReader reader = null; try { InputStream responseStream = client.get(url); reader = new InputStreamReader(responseStream, Charset.defaultCharset()); buffReader = new BufferedReader(reader); String line; StringBuilder strBuilder = new StringBuilder(); while ((line = buffReader.readLine()) != null) { strBuilder.append(line); } resp = strBuilder.toString(); return new JSONObject(new JSONTokener(resp)); } catch (IOException e) { throw new UncheckedIOException(e); } catch (JSONException e) { throw new SchemaException("failed to parse " + resp, e); } finally { try { if (buffReader != null) { buffReader.close(); } if (reader != null) { reader.close(); } } catch (IOException e) { throw new UncheckedIOException(e); } } }
From source file:io.werval.modules.json.JacksonJSON.java
@Override public JsonNode toNode(Object object) { try {/*from w w w.ja va 2 s . c o m*/ return mapper.readTree(mapper.writer().writeValueAsBytes(object)); } catch (JsonProcessingException ex) { throw new JsonPluginException(ex); } catch (IOException ex) { throw new UncheckedIOException(ex); } }
From source file:org.opendatakit.briefcase.reused.UncheckedFiles.java
public static Path createDirectories(Path dir, FileAttribute<?>... attrs) { try {/*w ww . j a v a 2 s . c o m*/ return Files.createDirectories(dir, attrs); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:jvmoptions.OptionAnalyzer.java
static Path toJson(String java6, String java7, String java8) throws Exception { Map<String, Map<String, String>> map6 = makeMap(java6); Map<String, Map<String, String>> map7 = makeMap(java7); Map<String, Map<String, String>> map8 = makeMap(java8); Path output = Paths.get("result", filename("json")); JsonFactory factory = new JsonFactory(); JsonGenerator jg = factory.createGenerator(output.toFile(), JsonEncoding.UTF8).useDefaultPrettyPrinter(); jg.writeStartObject();/*from w w w .j a va 2s. c o m*/ Stream.of(map6, map7, map8).map(Map::keySet).flatMap(Collection::stream).sorted().distinct().forEach(k -> { try { jg.writeFieldName(k); jg.writeStartObject(); Map<String, String> base = pick(k, map8, map7, map6); jg.writeStringField("kind", base.get("kind")); jg.writeStringField("type", base.get("type")); jg.writeStringField("description", base.get("description")); jg.writeStringField("file", base.get("file")); write(jg, "java6", map6.get(k)); write(jg, "java7", map7.get(k)); write(jg, "java8", map8.get(k)); jg.writeEndObject(); } catch (IOException e) { throw new UncheckedIOException(e); } }); jg.writeEndObject(); jg.close(); return output; }
From source file:org.opencb.commons.datastore.mongodb.GenericDocumentComplexConverter.java
@Override public Document convertToStorageType(T object) { try {// w w w .jav a 2 s . com String json = objectMapper.writeValueAsString(object); Document document = Document.parse(json); replaceDots(document); return document; } catch (JsonProcessingException e) { throw new UncheckedIOException(e); } }
From source file:org.trellisldp.test.TestUtils.java
/** * Read an http entity as a string./*from w w w . j a v a2 s. co m*/ * @param entity the entity * @return the entity as a string */ public static String readEntityAsString(final Object entity) { try { return IOUtils.toString((InputStream) entity, UTF_8); } catch (final IOException ex) { throw new UncheckedIOException(ex); } }