org.seasar.kvasir.util.io.IOUtils.closeQuietly()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中org.seasar.kvasir.util.io.IOUtils.closeQuietly()方法的一些代码示例,展示了IOUtils.closeQuietly()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.closeQuietly()方法的具体详情如下:
包路径:org.seasar.kvasir.util.io.IOUtils
类名称:IOUtils
方法名:closeQuietly

IOUtils.closeQuietly介绍

暂无

代码示例

代码示例来源:origin: org.seasar.kvasir.page.ability.content/org.seasar.kvasir.page.ability.content

void setBodyInputStream0(InputStream bodyInputStream)
{
  IOUtils.closeQuietly(bodyInputStream_);
  bodyInputStream_ = bodyInputStream;
}

代码示例来源:origin: org.seasar.kvasir/kvasir-util

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);
      }
    }
  }
}

代码示例来源:origin: org.seasar.kvasir/kvasir-util

} finally {
  if (closeInputStream) {
    closeQuietly(bis);
    closeQuietly(bos);

代码示例来源:origin: org.seasar.kvasir.cms.webdav/org.seasar.kvasir.cms.webdav

@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);
    }
  }
}

代码示例来源:origin: org.seasar.kvasir/kvasir-util

throw new IORuntimeException(ex);
} finally {
  closeQuietly(br);

代码示例来源:origin: org.seasar.ymir.vili/vili-api

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);
  }
}

代码示例来源:origin: org.seasar.kvasir.cms.java/org.seasar.kvasir.cms.java

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);
    }
  }
}

代码示例来源:origin: org.seasar.kvasir/kvasir-util

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);
    }
  }
}

代码示例来源:origin: org.seasar.ymir.vili/vili-api

IOUtils.closeQuietly(is);

代码示例来源:origin: org.seasar.ymir.vili/vili-api

IOUtils.closeQuietly(is);

代码示例来源:origin: org.seasar.kvasir.cms.webdav/org.seasar.kvasir.cms.webdav

@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);
  }
}

代码示例来源:origin: org.seasar.kvasir.page.ability.content/org.seasar.kvasir.page.ability.content

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());
  }
}

代码示例来源:origin: org.seasar.kvasir/kvasir-util

throw new IORuntimeException(ex);
} finally {
  IOUtils.closeQuietly(in1);
  IOUtils.closeQuietly(in2);

代码示例来源:origin: org.seasar.kvasir/kvasir-base

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);
  }
}

代码示例来源:origin: org.seasar.kvasir/kvasir-util

prop.store(out);
} finally {
  IOUtils.closeQuietly(out);
  IOUtils.closeQuietly(os);

代码示例来源:origin: org.seasar.kvasir.page.ability.table/org.seasar.kvasir.page.ability.table

} finally {
  DbUtils.closeQuietly(con, pst, rs);
  IOUtils.closeQuietly(os);

代码示例来源:origin: org.seasar.kvasir.cms.java/org.seasar.kvasir.cms.java

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);
    }
  }
}

代码示例来源:origin: org.seasar.kvasir.cms.java/org.seasar.kvasir.cms.java

@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);
  }
}

代码示例来源:origin: org.seasar.kvasir.page/org.seasar.kvasir.page

throw new IORuntimeException(ex);
} finally {
  IOUtils.closeQuietly(out);
  IOUtils.closeQuietly(os);

代码示例来源:origin: org.seasar.kvasir/kvasir-system

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();
}

相关文章