org.seasar.kvasir.util.io.IOUtils类的使用及代码示例

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

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

IOUtils介绍

暂无

代码示例

代码示例来源: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.ymir/ymir-testing

protected String readResource(Class<?> testClass, String name) {
  String className = testClass.getName();
  int dot = className.lastIndexOf('.');
  if (dot >= 0) {
    className = className.substring(dot + 1);
  }
  return IOUtils.readString(getClass().getResourceAsStream(
      className + "_" + name), "UTF-8", false);
}

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

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

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

public static byte[] readBytes(InputStream in)
{
  if (in == null) {
    return null;
  }
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  try {
    pipe(in, baos);
    baos.close();
    return baos.toByteArray();
  } catch (IOException ex) {
    throw new IORuntimeException(ex);
  }
}

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

public static void writeString(OutputStream os, String string,
  String encoding, boolean normalizeLineSeparator)
{
  writeString(os, string, encoding, normalizeLineSeparator, true);
}

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

public byte[] getBodyBytes()
{
  return IOUtils.readBytes(getBodyInputStream());
}

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

public static void writeBytes(OutputStream out, byte[] bytes)
{
  writeBytes(out, bytes, true);
}

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

protected boolean doProcessFile(HttpServletRequest request,
  HttpServletResponse response, PageRequest pageRequest, File file)
  throws ServletException, IOException
{
  String mimeType = context_.getMimeType(pageRequest.getMy()
    .getLocalPathname());
  if (mimeType != null) {
    response.setContentType(mimeType);
  }
  response.setDateHeader("Last-Modified", file.lastModified());
  IOUtils.pipe(new FileInputStream(file), response.getOutputStream(),
    true, false);
  return true;
}

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

public static void writeString(Writer writer, String string,
  boolean normalizeLineSeparator)
{
  writeString(writer, string, normalizeLineSeparator, true);
}

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

@Override
  public byte[] getContent()
  {
    try {
      return IOUtils.readBytes(streamContent());
    } catch (IOException ex) {
      throw new IORuntimeException("Can't get content: " + element_, ex);
    }
  }
}

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

void commit(byte[] response) throws IOException {
    IOUtils.writeBytes(getResponse().getOutputStream(), response, false);
  }
}

代码示例来源: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.page.ability.content/org.seasar.kvasir.page.ability.content

public String toHTML(InputStream in, String encoding, String type,
  VariableResolver resolver)
{
  if (in == null) {
    return null;
  }
  if (encoding == null) {
    encoding = ENCODING_DEFAULT;
  }
  return engine_.evaluate(IOUtils.readString(in, encoding, false));
}

代码示例来源: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.base.webapp/org.seasar.kvasir.base.webapp

public void doProcess(HttpServletRequest request,
    HttpServletResponse response, RequestProcessorChain chain)
    throws ServletException, IOException
  {
    String path = ServletUtils.getPath(request);
    Content content = contentByPathMap_.get(path);
    if (content != null) {
      String contentType = content.getContentType();
      if (contentType == null) {
        contentType = context_.getMimeType(path);
      }
      if (contentType != null) {
        response.setContentType(contentType);
      }
      response.setDateHeader("Last-Modified", content
        .getLastModifiedTime());
      // responseのoutputStreamのクローズ処理はコンテナに任せるのが吉なので
      // 閉じないように指定している。
      IOUtils.pipe(content.getInputStream(), response.getOutputStream(),
        true, false);
      return;
    }

    chain.doProcess(request, response);
  }
}

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

public static void writeString(OutputStream os, String string,
  String encoding, boolean normalizeLineSeparator, boolean close)
{
  try {
    writeString(new OutputStreamWriter(os, encoding), string,
      normalizeLineSeparator, close);
  } catch (UnsupportedEncodingException ex) {
    throw new IORuntimeException(ex);
  }
}

代码示例来源: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.page/org.seasar.kvasir.page

public String readText(String resourceName)
  {
    String resourcePath = getClass().getName().replace('.', '/')
      .concat("_").concat(resourceName);
    InputStream in = getClass().getClassLoader().getResourceAsStream(
      resourcePath);
    if (in == null) {
      throw new IORuntimeException("Specified resource does not exist: "
        + resourcePath);
    }
    return IOUtils.readString(in, "UTF-8", true);
  }
}

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

if (name.equals(classesPath + path)) {
    File file = new File(tempDir, classesPath + PATH_DELIMITER + path);
    IOUtils.pipe(jis, new FileOutputStream(file), false, true);
    file.deleteOnExit();
    return file.toURI().toURL();
      if (n.equals(path)) {
        File file = new File(tempDir, name + PATH_DELIMITER + path);
        IOUtils.pipe(jis, new FileOutputStream(file), false, true);
        file.deleteOnExit();
        return file.toURI().toURL();
IOUtils.closeQuietly(is);

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

IOUtils.pipe(attr.getStream(key).getInputStream(),
    stream.getOutputStream());
} catch (IOException ex) {

相关文章