@Override public Output append(CharSequence csq) { if (null == csq) { return this; } try { appendable.append(csq); } catch (IOException e) { throw E.ioException(e); } return this; }
public static File file(File parent, String path) { try { return new File(parent, path).getCanonicalFile(); } catch (IOException e) { throw E.ioException(e); } } }
@Override public URL getPersistenceUnitRootUrl() { try { return new File(".").toURI().toURL(); } catch (IOException e) { throw E.ioException(e); } }
private static ConsoleReader console(ActionContext actionContext, OutputStream os) { try { return new CliOverHttpConsole(actionContext, os); } catch (IOException e) { throw E.ioException(e); } }
private boolean checkThresholding(int bytes) { if (!exceedThreshold && (written + bytes > threshold)) { exceedThreshold = true; fileOutputStream = createFileOutputStream(); try { fileOutputStream.write(buf, 0, written); } catch (IOException e) { throw E.ioException(e); } } return exceedThreshold; }
public static String readContent(JarFile jar, JarEntry entry) { try { InputStream is = jar.getInputStream(entry); return IO.readContentAsString(is); } catch (IOException e) { throw E.ioException(e); } }
public static byte[] getBytes(JarFile jar, JarEntry entry) { try { InputStream is = jar.getInputStream(entry); ByteArrayOutputStream baos = new ByteArrayOutputStream(); IO.copy(is, baos); return baos.toByteArray(); } catch (IOException e) { throw E.ioException(e); } }
private Workbook loadWorkbook() { InputStream is = inputStreamProvider.apply(); try { return isXlsx ? new XSSFWorkbook(is) : new HSSFWorkbook(is); } catch (IOException e) { throw E.ioException(e); } }
public static <T> byte[] serialize(T obj) { E.NPE(obj); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(obj); oos.close(); return baos.toByteArray(); } catch (IOException e) { throw E.ioException(e); } }
private SObject resolveFromURL(String url) { try { Response resp = http().newCall(new Request.Builder().url(url).build()).execute(); return SObject.of(resp.body().byteStream()); } catch (IOException e) { throw E.ioException(e); } }
private OutputStream createFileOutputStream() { File dir = file.getParentFile(); if (!dir.exists() && !dir.mkdirs()) { throw E.ioException("Cannot create dir: " + dir.getAbsolutePath()); } return IO.buffered(IO.outputStream(file)); } }
public Map<String, Object> load(URL yamlFile, String modelPackage, DaoLocator daoLocator) { try { return load(IO.readContentAsString(yamlFile.openStream()), modelPackage, daoLocator); } catch (IOException e) { throw E.ioException(e); } }
public static List<String> readLines(File file, String encoding, int limit) { InputStream is = null; try { is = new FileInputStream(file); return readLines(is, encoding, limit); } catch (IOException ex) { throw E.ioException(ex); } finally { close(is); } }
private void println0(String template, Object... args) { try { if (args.length > 0) { template = S.fmt(template); } console.println(template); } catch (IOException e) { throw E.ioException(e); } }
public static ISObject store(FileItemStream fileItemStream, App app) { UploadFileStorageService ss = app.uploadFileStorageService(); try { return ss._store(fileItemStream); } catch (IOException e) { throw E.ioException(e); } }
private void print0(String template, Object... args) { try { console.print(S.fmt(template, args)); } catch (IOException e) { throw E.ioException(e); } }
public InputStream toInputStream() { try { return load(); } catch (IOException e) { throw E.ioException(e); } finally { ensureCloseSource(); } }
public Builder inputStream(final InputStream is) { InputStream probeStream = pushbackInputStream(is); try { return inputStream(probeStream, FileMagic.valueOf(probeStream) == FileMagic.OOXML); } catch (IOException e) { throw E.ioException(e); } }
private void print0(String template, Object... args) { try { console.print(S.fmt(template, args)); } catch (IOException e) { throw E.ioException(e); } }
private void commit(Workbook workbook, OutputStream os) { try { workbook.write(os); } catch (IOException e) { throw E.ioException(e); } finally { if (workbook instanceof SXSSFWorkbook) { ((SXSSFWorkbook) workbook).dispose(); } IO.close(os); } }