List of usage examples for java.io UncheckedIOException UncheckedIOException
public UncheckedIOException(IOException cause)
From source file:com.github.blindpirate.gogradle.util.IOUtils.java
public static void copyFile(File src, File dest) { try {//from w ww. ja v a2s.c o m FileUtils.copyFile(src, dest); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:objective.taskboard.utils.ZipUtils.java
public static void zip(Stream<ZipStreamEntry> stream, Path output) { if (output.toFile().isDirectory()) throw new RuntimeException("Output must be a file"); try (OutputStream outputStream = Files.newOutputStream(output)) { zip(stream, outputStream);/* w ww . jav a 2s .c om*/ } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:org.apache.bookkeeper.tools.perf.dlog.PerfReader.java
void read(List<DistributedLogManager> logs) throws Exception { log.info("Read thread started with : logs = {}", logs.stream().map(l -> l.getStreamName()).collect(Collectors.toList())); List<LogReader> readers = logs.stream().map(manager -> { try {/*from w w w . j a v a2 s . c om*/ return manager.openLogReader(DLSN.InitialDLSN); } catch (IOException e) { log.error("Failed to open reader for log stream {}", manager.getStreamName(), e); throw new UncheckedIOException(e); } }).collect(Collectors.toList()); final int numLogs = logs.size(); while (true) { for (int i = 0; i < numLogs; i++) { LogRecordWithDLSN record = readers.get(i).readNext(true); if (null != record) { recordsRead.increment(); bytesRead.add(record.getPayloadBuf().readableBytes()); } } } }
From source file:org.trellisldp.test.TestUtils.java
/** * Get a resource as a string./*from w w w.j av a 2 s .c om*/ * @param path the resource path * @return the resource as a string */ public static String getResourceAsString(final String path) { final InputStream is = TestUtils.class.getResourceAsStream(path); if (nonNull(is)) { try { return IOUtils.toString(is, UTF_8); } catch (final IOException ex) { throw new UncheckedIOException(ex); } } return null; }
From source file:edu.umd.umiacs.clip.tools.io.AllFiles.java
protected static Runnable asUncheckedRunnable(Closeable c) { return () -> { try {//from w w w .j a v a2s . co m c.close(); } catch (IOException e) { throw new UncheckedIOException(e); } }; }
From source file:de.siegmar.securetransfer.component.Cryptor.java
public byte[] encrypt(final byte[] src, final KeyIv keyIv) { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (final OutputStream out = getCryptOut(bos, keyIv)) { ByteStreams.copy(new ByteArrayInputStream(src), out); } catch (final IOException e) { throw new UncheckedIOException(e); }/*from www. ja va 2 s .co m*/ return bos.toByteArray(); }
From source file:org.opencb.opencga.storage.hadoop.variant.metadata.HBaseStudyConfigurationManager.java
@Override public void unLockStudy(int studyId, long lockToken) { try {//w w w . ja va 2s. com lock.unlock(Bytes.toBytes(studyId + "_LOCK"), lockToken); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:io.werval.modules.json.JacksonJSON.java
@Override public <T> T updateFromJSON(T object, byte[] json) { try {// w w w. ja v a2 s. co m return mapper.readerForUpdating(object).readValue(json); } catch (JsonProcessingException ex) { throw new JsonPluginException(ex); } catch (IOException ex) { throw new UncheckedIOException(ex); } }
From source file:com.linkedin.gradle.python.tasks.action.pip.PipWheelAction.java
private boolean doesWheelExist(PackageInfo packageInfo) { Optional<File> wheel = wheelCache.findWheel(packageInfo.getName(), packageInfo.getVersion(), pythonDetails); if (wheel.isPresent()) { File wheelFile = wheel.get(); try {/*from ww w . java2s . c om*/ FileUtils.copyFile(wheelFile, new File(wheelExtension.getWheelCache(), wheelFile.getName())); } catch (IOException e) { throw new UncheckedIOException(e); } if (PythonHelpers.isPlainOrVerbose(project)) { logger.lifecycle("Skipping {}, in wheel cache {}", packageInfo.toShortHand(), wheelFile); } return true; } ConfigurableFileTree tree = project.fileTree(wheelExtension.getWheelCache(), action -> { String sanitizedName = packageInfo.getName().replace('-', '_'); String sanitizedVersion = (packageInfo.getVersion() == null ? "unspecified" : packageInfo.getVersion()) .replace('-', '_'); action.include("**/" + sanitizedName + "-" + sanitizedVersion + "-*.whl"); }); if (tree.getFiles().size() >= 1) { logger.lifecycle("Skipping {} wheel - Installed", packageInfo.toShortHand()); return true; } return false; }
From source file:org.cryptomator.filesystem.crypto.CryptoFolder.java
private Stream<File> nonConflictingFiles() { if (exists()) { final Stream<? extends File> files = physicalFolder().filter(Folder::exists).map(Folder::files) .orElse(Stream.empty()); return files.filter(startsWithEncryptedName()).map(conflictResolver::resolveIfNecessary).distinct(); } else {//from w ww . j ava2s. co m throw new UncheckedIOException(new FileNotFoundException(format("Folder %s does not exist", this))); } }