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

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

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

IOUtils.pipe介绍

暂无

代码示例

代码示例来源: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.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.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.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();
  urlList.add(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();
      urlList.add(file.toURI().toURL());

代码示例来源: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();

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

public static void pipe(InputStream in, OutputStream out,
  boolean closeInputStream, boolean closeOutputStream)
  throws IOException
{
  BufferedInputStream bis;
  if (in instanceof BufferedInputStream) {
    bis = (BufferedInputStream)in;
  } else {
    bis = new BufferedInputStream(in);
  }
  BufferedOutputStream bos;
  if (out instanceof BufferedOutputStream) {
    bos = (BufferedOutputStream)out;
  } else {
    bos = new BufferedOutputStream(out);
  }
  try {
    byte[] buf = new byte[BUF_SIZE];
    int len;
    while ((len = bis.read(buf)) != -1) {
      bos.write(buf, 0, len);
    }
    bos.flush();
  } finally {
    if (closeInputStream) {
      closeQuietly(bis);
    }
    if (closeOutputStream) {
      closeQuietly(bos);
    }

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

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

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

try {
  tempFile = File.createTempFile("kvasir", null);
  IOUtils.pipe(archive_.getInputStream(), new FileOutputStream(
    tempFile));
  zipFile = new ZipFile(tempFile);

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

is = mold.getBodyInputStream();
  os = resource.getOutputStream();
  IOUtils.pipe(is, os);
} catch (IOException ex) {
  throw new IORuntimeException(ex);

相关文章