info.aduna.io.IOUtil.transfer()方法的使用及代码示例

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

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

IOUtil.transfer介绍

[英]Writes all bytes from an InputStream to a file.
[中]将输入流中的所有字节写入文件。

代码示例

代码示例来源:origin: info.aduna.commons/aduna-commons-io

public static void writeBytes(byte[] data, OutputStream out)
  throws IOException
{
  transfer(new ByteArrayInputStream(data), out);
}

代码示例来源:origin: org.openrdf.sesame/sesame-http-client

public void writeTo(OutputStream out)
    throws IOException
  {
    try {
      OutputStreamWriter writer = new OutputStreamWriter(out, charset);
      IOUtil.transfer(contents, writer);
      writer.flush();
    }
    finally {
      contents.close();
    }
  }
};

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
 * Reads all bytes from the supplied input stream and returns them as a byte
 * array.
 * 
 * @param in
 *        The InputStream supplying the bytes.
 * @return A byte array containing all bytes from the supplied input stream.
 */
public static byte[] readBytes(InputStream in)
  throws IOException
{
  ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
  transfer(in, out);
  return out.toByteArray();
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
 * Writes all bytes from an <tt>InputStream</tt> to a file.
 * 
 * @param in
 *        The <tt>InputStream</tt> containing the data to write to the file.
 * @param file
 *        The file to write the data to.
 * @return The total number of bytes written.
 * @throws IOException
 *         If an I/O error occured while trying to write the data to the
 *         file.
 */
public static final long transfer(InputStream in, File file)
  throws IOException
{
  FileOutputStream out = new FileOutputStream(file);
  try {
    return transfer(in, out);
  }
  finally {
    out.close();
  }
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
 * Store a resource to a file on the file system.
 * 
 * @param resourceName
 *        the name of the resource
 * @param output
 *        the file to write to
 * @throws IOException
 *         if there was a problem reading the resource or writing to the file
 */
public static void resourceToFile(String resourceName, File output)
  throws IOException
{
  output.getParentFile().mkdirs();
  InputStream in = ResourceUtil.class.getResourceAsStream(resourceName);
  OutputStream out = new FileOutputStream(output);
  IOUtil.transfer(in, out);
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
   * Writes all characters from a <tt>Reader</tt> to a file using the default
   * character encoding.
   * 
   * @param reader
   *        The <tt>Reader</tt> containing the data to write to the file.
   * @param file
   *        The file to write the data to.
   * @return The total number of characters written.
   * @throws IOException
   *         If an I/O error occured while trying to write the data to the
   *         file.
   * @see java.io.FileWriter
   */
  public static final long transfer(Reader reader, File file)
    throws IOException
  {
    FileWriter writer = new FileWriter(file);

    try {
      return transfer(reader, writer);
    }
    finally {
      writer.close();
    }
  }
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
 * Writes all data that can be read from the supplied InputStream to the
 * specified file.
 * 
 * @param in
 *        An InputStream.
 * @param file
 *        The file to write the data to.
 * @throws IOException
 *         If an I/O error occurred.
 */
public static void writeStream(InputStream in, File file)
  throws IOException
{
  FileOutputStream out = new FileOutputStream(file);
  try {
    transfer(in, out);
  }
  finally {
    try {
      out.flush();
    }
    finally {
      out.close();
    }
  }
}

代码示例来源:origin: info.aduna.appbase/aduna-appbase-webapp-base-core

response.setContentLength(contentLength);
IOUtil.transfer(content, out);

代码示例来源:origin: org.openrdf.sesame/sesame-http-server-spring

response.setContentLength(contentLength);
IOUtil.transfer(content, out);

相关文章