/** * Reads all lines of text from this source, running the given {@code action} for each line as it * is read. * * <p>Like {@link BufferedReader#readLine()}, this method considers a line to be a sequence of * text that is terminated by (but does not include) one of {@code \r\n}, {@code \r} or {@code * \n}. If the source's content does not end in a line termination sequence, it is treated as if * it does. * * @throws IOException if an I/O error occurs while reading from this source or if {@code action} * throws an {@code UncheckedIOException} * @since 22.0 */ @Beta public void forEachLine(Consumer<? super String> action) throws IOException { try (Stream<String> lines = lines()) { // The lines should be ordered regardless in most cases, but use forEachOrdered to be sure lines.forEachOrdered(action); } catch (UncheckedIOException e) { throw e.getCause(); } }
/** * Refresh all partitions to make newly inserted data visible for readers. * * @throws IOException */ public void maybeRefreshBlocking() throws IOException { try { getPartitions().parallelStream().forEach( this::maybeRefreshPartition ); } catch ( UncheckedIOException e ) { throw e.getCause(); } }
/** * Reads all lines of text from this source, running the given {@code action} for each line as it * is read. * * <p>Like {@link BufferedReader#readLine()}, this method considers a line to be a sequence of * text that is terminated by (but does not include) one of {@code \r\n}, {@code \r} or {@code * \n}. If the source's content does not end in a line termination sequence, it is treated as if * it does. * * @throws IOException if an I/O error occurs while reading from this source or if {@code action} * throws an {@code UncheckedIOException} * @since 22.0 */ @Beta public void forEachLine(Consumer<? super String> action) throws IOException { try (Stream<String> lines = lines()) { // The lines should be ordered regardless in most cases, but use forEachOrdered to be sure lines.forEachOrdered(action); } catch (UncheckedIOException e) { throw e.getCause(); } }
/** * Reads all lines of text from this source, running the given {@code action} for each line as it * is read. * * <p>Like {@link BufferedReader#readLine()}, this method considers a line to be a sequence of * text that is terminated by (but does not include) one of {@code \r\n}, {@code \r} or {@code * \n}. If the source's content does not end in a line termination sequence, it is treated as if * it does. * * @throws IOException if an I/O error occurs while reading from this source or if {@code action} * throws an {@code UncheckedIOException} * @since 22.0 */ @Beta public void forEachLine(Consumer<? super String> action) throws IOException { try (Stream<String> lines = lines()) { // The lines should be ordered regardless in most cases, but use forEachOrdered to be sure lines.forEachOrdered(action); } catch (UncheckedIOException e) { throw e.getCause(); } }
if (!(e.getCause() instanceof EOFException)) { throw e;
.collect(toCollection(TreeSet::new)); } catch (UncheckedIOException e) { throw e.getCause();
throw ex.getCause();
/** Return the cumulative size of all files in this directory. */ long estimateSizeInBytes() throws IOException { try { return size.getOrRefresh().size; } catch (UncheckedIOException e) { // we wrapped in the cache and unwrap here throw e.getCause(); } }
public static <T> T waitFor(Future<T> future) { try { return future.get(); } catch (ExecutionException e) { if (e.getCause() instanceof IOException) { throw new UncheckedIOException(e.getCause().getMessage(), (IOException) e.getCause()); } else if (e.getCause() instanceof UncheckedIOException) { throw new UncheckedIOException( e.getCause().getMessage(), ((UncheckedIOException) e.getCause()).getCause()); } else if (e.getCause() instanceof CommandExecutionException) { throw new CommandExecutionException(e.getCause().getMessage(), e.getCause()); } else { throw new RuntimeException(e.getMessage(), e); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException("One operation was interrupted.", e); } }
/** * It is intended that once the BlockRead object is returned to the caller, that the caller will * read the entire block and then call close on the BlockRead class. */ public CachedBlockRead getMetaBlock(String blockName) throws IOException { if (_iCache != null) { String _lookup = this.cacheId + "M" + blockName; try { CacheEntry ce = _iCache.getBlock(_lookup, new MetaBlockLoader(blockName)); if (ce != null) { return new CachedBlockRead(ce, ce.getBuffer()); } } catch (UncheckedIOException uioe) { if (uioe.getCause() instanceof MetaBlockDoesNotExist) { // When a block does not exists, its expected that MetaBlockDoesNotExist is thrown. // However do not want to throw cause, because stack trace info // would be lost. So rewrap and throw ino rder to preserve full stack trace. throw new MetaBlockDoesNotExist(uioe); } throw uioe; } } BlockReader _currBlock = getBCFile(null).getMetaBlock(blockName); return new CachedBlockRead(_currBlock); }
@Override public T next() throws IOException { try { return iterator.next(); } catch (UncheckedIOException e) { throw e.getCause(); } }
@Override public boolean hasNext() throws IOException { try { return iterator.hasNext(); } catch (UncheckedIOException e) { throw e.getCause(); } };
try(Writer writer = Files.newBufferedWriter(mOutputPath)) { mHashMap.forEach((key, value) -> { try { writer.write(key + DATA_SEPARATOR + value + System.lineSeparator()); } catch (IOException ex) { throw new UncheckedIOException(ex); } }); } catch(UncheckedIOException ex) { throw ex.getCause(); }
@Override public FileVisitResult visitFile(T file, BasicFileAttributes attrs) throws IOException { try { return visitFile.apply(Objects.requireNonNull(file), Objects.requireNonNull(attrs)); } catch (UncheckedIOException e) { throw e.getCause(); } }
@Override public void close() throws IOException { try { stream.close(); } catch (UncheckedIOException e) { throw e.getCause(); } } }
/** Return the cumulative size of all files in this directory. */ long estimateSizeInBytes() throws IOException { try { return size.getOrRefresh().size; } catch (UncheckedIOException e) { // we wrapped in the cache and unwrap here throw e.getCause(); } }
@Override public String getAccessToken() throws IOException { try { return token.updateAndGet(ZignAccessTokenProvider::update).value; } catch (UncheckedIOException e) { throw e.getCause(); } }
protected List<WatchedFile> getWatchedFileList(String path) throws IOException { try { return Files.list(Paths.get(path)) .map(p -> new WatchedFile(p.toString(), false, fileSize(p))) .sorted(Comparator.comparing(WatchedFile::getFileName)) .collect(Collectors.toList()); } catch(UncheckedIOException ex) { throw ex.getCause(); } } private long fileSize(Path path) { try { return Files.size(path); } catch (IOException ex) { throw new UncheckedIOException(ex); } }
private List<SnapshotItem> fetchLatest(List<ContentSpecifier> specs) throws IOException { try { return specs.stream().map(ioCheck(spec -> fetchLatest(spec))).filter(item -> item.isPresent()) .map(item -> item.get()).collect(Collectors.toList()); } catch (UncheckedIOException e) { throw e.getCause(); } }
@Override public Object evaluate(Tuple tuple) throws IOException { try{ List<Object> containedResults = recursivelyEvaluate(tuple); // this needs to be treated as an array of objects when going into doWork(Object ... values) return normalizeOutputType(doWork(containedResults.toArray())); } catch(UncheckedIOException e){ throw e.getCause(); } }