void setBodyInputStream0(InputStream bodyInputStream) { IOUtils.closeQuietly(bodyInputStream_); bodyInputStream_ = bodyInputStream; }
public static void writeBytes(OutputStream out, byte[] bytes, boolean close) { BufferedOutputStream bos; if (out instanceof BufferedOutputStream) { bos = (BufferedOutputStream)out; } else { bos = new BufferedOutputStream(out); } try { bos.write(bytes); bos.flush(); } catch (IOException ex) { throw new IORuntimeException(ex); } finally { if (close) { closeQuietly(out); } } } }
} finally { if (closeInputStream) { closeQuietly(bis); closeQuietly(bos);
@Override protected void setContent(PageElement element, String encoding, InputStream in) throws NamingException { if (TYPE_ATTACHED.equals(element.getType())) { // inはnullのはずだが、念のため。 IOUtils.closeQuietly(in); } else { setPageContent(element, encoding, in); } } }
throw new IORuntimeException(ex); } finally { closeQuietly(br);
byte[] getResourceBytes(String path) { InputStream is = null; try { is = jarURL.openStream(); JarInputStream jis = new JarInputStream(is); for (JarEntry entry = jis.getNextJarEntry(); entry != null; entry = jis.getNextJarEntry()) { String name = entry.getName(); if (name.equals(classesPath + path)) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.pipe(jis, baos, false, false); return baos.toByteArray(); } else if (name.startsWith(libPath) && name.toLowerCase().endsWith(SUFFIX_JAR)) { JarInputStream jjis = new JarInputStream(jis); for (JarEntry e = jjis.getNextJarEntry(); e != null; e = jjis.getNextJarEntry()) { String n = e.getName(); if (n.equals(path)) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.pipe(jjis, baos, false, false); return baos.toByteArray(); } } } } return null; } catch (IOException ex) { return null; } finally { IOUtils.closeQuietly(is); } }
void compile() { InputStream in = null; try { in = new FileInputStream(file_); clazz_ = plugin_.compileClassBody(new InputStreamReader(in, encoding_), Base.class, Thread.currentThread() .getContextClassLoader()); lastModified_ = System.currentTimeMillis(); } catch (CompileException ex) { throw new IORuntimeException(ex); } catch (IOException ex) { throw new IORuntimeException(ex); } finally { IOUtils.closeQuietly(in); } } }
public static void writeString(Writer writer, String string, boolean normalizeLineSeparator, boolean close) { try { BufferedWriter bw = null; if (writer instanceof BufferedWriter) { bw = (BufferedWriter)writer; } else { bw = new BufferedWriter(writer); } bw.write(normalizeLineSeparator ? StringUtils .normalizeLineSeparator(string) : string); bw.flush(); } catch (IOException ex) { throw new IORuntimeException(ex); } finally { if (close) { closeQuietly(writer); } } }
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(is);
@Override protected void create(PageElement element, String encoding, InputStream in) throws NamingException { if (TYPE_ATTACHED.equals(element.getType())) { // inはnullのはずだが、念のため。 IOUtils.closeQuietly(in); // ページがなければ作る。 getPage(element, true, false); } else { createPageContent(element, encoding, in); } }
void updateContent(final Page page, final String variant, final ContentMold mold, final boolean overwrite) { try { page.runWithLocking(new Processable<Object>() { public Object process() throws ProcessableRuntimeException { synchronized (ContentAbilityAlfrImpl.this) { cache_.updateContent(page.getDto().getId(), variant, mold, overwrite); } return null; } }); } finally { IOUtils.closeQuietly(mold.getBodyInputStream()); } }
throw new IORuntimeException(ex); } finally { IOUtils.closeQuietly(in1); IOUtils.closeQuietly(in2);
public synchronized void store() { if (customConfigResource_ == null) { return; } Resource storeResource = new FileResource(ClassUtils .getFileOfResource(customConfigResource_)); OutputStream os = null; Writer out = null; try { os = storeResource.getOutputStream(); out = new OutputStreamWriter(os, "UTF-8"); os = null; store(out); } catch (IOException ex) { throw new IORuntimeException(ex); } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(os); } }
prop.store(out); } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(os);
} finally { DbUtils.closeQuietly(con, pst, rs); IOUtils.closeQuietly(os);
public ClassLoader compile(Reader javaSource, ClassLoader classLoader) throws CompileException { try { return new SimpleCompiler(new Scanner(null, javaSource), classLoader).getClassLoader(); } catch (Throwable t) { throw new CompileException(t); } finally { IOUtils.closeQuietly(javaSource); } } }
@SuppressWarnings("unchecked") public <S> Class<S> compileClassBody(Reader classBody, Class<S> superClass, ClassLoader classLoader) throws CompileException { try { return new ClassBodyEvaluator(new Scanner(null, classBody), superClass, new Class[0], classLoader).getClazz(); } catch (Throwable t) { throw new CompileException(t); } finally { IOUtils.closeQuietly(classBody); } }
throw new IORuntimeException(ex); } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(os);
public void storeSettings(final PluginAlfrSettings settings) { final Resource configurationDirectory = kvasir_ .getConfigurationDirectory(); final Resource systemDirectory = configurationDirectory .getChildResource(Globals.SYSTEM_DIR); if (!systemDirectory.exists()) { if (!systemDirectory.mkdirs()) { throw new RuntimeException("can't create directory [" + systemDirectory.toFile() + "]"); } } final Resource storeFile = systemDirectory .getChildResource(PluginAlfrImpl.SETTINGS_FILE_NAME); OutputStream os = null; try { os = storeFile.getOutputStream(); XOMUtils.toXML(settings, os); } catch (final ResourceNotFoundException ex) { throw new RuntimeException(ex); } catch (final IOException ex) { throw new IORuntimeException(ex); } catch (ValidationException ex) { throw new RuntimeException(ex); } finally { IOUtils.closeQuietly(os); } constructSettings(); }