本文整理了Java中cn.hutool.core.io.FileUtil.getOutputStream()
方法的一些代码示例,展示了FileUtil.getOutputStream()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.getOutputStream()
方法的具体详情如下:
包路径:cn.hutool.core.io.FileUtil
类名称:FileUtil
方法名:getOutputStream
[英]获得一个输出流对象
[中]获得一个输出流对象
代码示例来源:origin: looly/hutool
/**
* 获得 {@link ZipOutputStream}
*
* @param zipFile 压缩文件
* @param charset 编码
* @return {@link ZipOutputStream}
*/
private static ZipOutputStream getZipOutputStream(File zipFile, Charset charset) {
return getZipOutputStream(FileUtil.getOutputStream(zipFile), charset);
}
代码示例来源:origin: looly/hutool
/**
* 获得一个输出流对象
*
* @param path 输出到的文件路径,绝对路径
* @return 输出流对象
* @throws IORuntimeException IO异常
*/
public static BufferedOutputStream getOutputStream(String path) throws IORuntimeException {
return getOutputStream(touch(path));
}
代码示例来源:origin: looly/hutool
/**
* 获得 {@link ZipOutputStream}
*
* @param zipFile 压缩文件
* @param charset 编码
* @return {@link ZipOutputStream}
*/
private static ZipOutputStream getZipOutputStream(File zipFile, Charset charset) {
return getZipOutputStream(FileUtil.getOutputStream(zipFile), charset);
}
代码示例来源:origin: looly/hutool
/**
* 获得一个输出流对象
*
* @param path 输出到的文件路径,绝对路径
* @return 输出流对象
* @throws IORuntimeException IO异常
*/
public static BufferedOutputStream getOutputStream(String path) throws IORuntimeException {
return getOutputStream(touch(path));
}
代码示例来源:origin: looly/hutool
/**
* 将Excel Workbook刷出到文件<br>
* 如果用户未自定义输出的文件,将抛出{@link NullPointerException}
*
* @param destFile 写出到的文件
* @return this
* @throws IORuntimeException IO异常
*/
public Word07Writer flush(File destFile) throws IORuntimeException {
Assert.notNull(destFile, "[destFile] is null, and you must call setDestFile(File) first or call flush(OutputStream).");
return flush(FileUtil.getOutputStream(destFile), true);
}
代码示例来源:origin: looly/hutool
/**
* 将Excel Workbook刷出到文件<br>
* 如果用户未自定义输出的文件,将抛出{@link NullPointerException}
*
* @param destFile 写出到的文件
* @return this
* @throws IORuntimeException IO异常
*/
public Word07Writer flush(File destFile) throws IORuntimeException {
Assert.notNull(destFile, "[destFile] is null, and you must call setDestFile(File) first or call flush(OutputStream).");
return flush(FileUtil.getOutputStream(destFile), true);
}
代码示例来源:origin: looly/hutool
@Override
public void render(Map<?, ?> bindingMap, File file) {
BufferedOutputStream out = null;
try {
out = FileUtil.getOutputStream(file);
this.render(bindingMap, out);
} finally {
IoUtil.close(out);
}
}
代码示例来源:origin: looly/hutool
@Override
public void render(Map<?, ?> bindingMap, File file) {
BufferedOutputStream out = null;
try {
out = FileUtil.getOutputStream(file);
this.render(bindingMap, out);
} finally {
IoUtil.close(out);
}
}
代码示例来源:origin: looly/hutool
/**
* 将Excel Workbook刷出到文件<br>
* 如果用户未自定义输出的文件,将抛出{@link NullPointerException}
*
* @param destFile 写出到的文件
* @return this
* @throws IORuntimeException IO异常
* @since 4.0.6
*/
public ExcelWriter flush(File destFile) throws IORuntimeException {
Assert.notNull(destFile, "[destFile] is null, and you must call setDestFile(File) first or call flush(OutputStream).");
return flush(FileUtil.getOutputStream(destFile), true);
}
代码示例来源:origin: looly/hutool
/**
* 将Excel Workbook刷出到文件<br>
* 如果用户未自定义输出的文件,将抛出{@link NullPointerException}
*
* @param destFile 写出到的文件
* @return this
* @throws IORuntimeException IO异常
* @since 4.0.6
*/
public ExcelWriter flush(File destFile) throws IORuntimeException {
Assert.notNull(destFile, "[destFile] is null, and you must call setDestFile(File) first or call flush(OutputStream).");
return flush(FileUtil.getOutputStream(destFile), true);
}
代码示例来源:origin: looly/hutool
/**
* 验证码写出到文件
*
* @param file 文件
* @throws IORuntimeException IO异常
*/
public void write(File file) throws IORuntimeException {
try (OutputStream out = FileUtil.getOutputStream(file)) {
this.write(out);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
代码示例来源:origin: looly/hutool
/**
* 验证码写出到文件
*
* @param file 文件
* @throws IORuntimeException IO异常
*/
public void write(File file) throws IORuntimeException {
try (OutputStream out = FileUtil.getOutputStream(file)) {
this.write(out);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
代码示例来源:origin: looly/hutool
/**
* 下载文件
*
* @param path 文件路径
* @param fileName 文件名
* @param outFile 输出文件或目录
*/
public void download(String path, String fileName, File outFile) {
if (outFile.isDirectory()) {
outFile = new File(outFile, fileName);
}
if (false == outFile.exists()) {
FileUtil.touch(outFile);
}
try (OutputStream out = FileUtil.getOutputStream(outFile)) {
download(path, fileName, out);
} catch (IOException e) {
throw new FtpException(e);
}
}
代码示例来源:origin: looly/hutool
/**
* 下载文件
*
* @param path 文件路径
* @param fileName 文件名
* @param outFile 输出文件或目录
*/
public void download(String path, String fileName, File outFile) {
if (outFile.isDirectory()) {
outFile = new File(outFile, fileName);
}
if (false == outFile.exists()) {
FileUtil.touch(outFile);
}
try (OutputStream out = FileUtil.getOutputStream(outFile)) {
download(path, fileName, out);
} catch (IOException e) {
throw new FtpException(e);
}
}
代码示例来源:origin: looly/hutool
/**
* 从Zip文件流中拷贝文件出来
*
* @param zipFile Zip文件
* @param zipEntry zip文件中的子文件
* @param outItemFile 输出到的文件
* @throws IOException IO异常
*/
private static void copy(ZipFile zipFile, ZipEntry zipEntry, File outItemFile) throws IOException {
InputStream in = null;
OutputStream out = null;
try {
in = zipFile.getInputStream(zipEntry);
out = FileUtil.getOutputStream(outItemFile);
IoUtil.copy(in, out);
} finally {
IoUtil.close(out);
IoUtil.close(in);
}
}
代码示例来源:origin: looly/hutool
/**
* 从Zip文件流中拷贝文件出来
*
* @param zipFile Zip文件
* @param zipEntry zip文件中的子文件
* @param outItemFile 输出到的文件
* @throws IOException IO异常
*/
private static void copy(ZipFile zipFile, ZipEntry zipEntry, File outItemFile) throws IOException {
InputStream in = null;
OutputStream out = null;
try {
in = zipFile.getInputStream(zipEntry);
out = FileUtil.getOutputStream(outItemFile);
IoUtil.copy(in, out);
} finally {
IoUtil.close(out);
IoUtil.close(in);
}
}
代码示例来源:origin: looly/hutool
/**
* 将可序列化的对象转换为XML写入文件,已经存在的文件将被覆盖<br>
* Writes serializable object to a XML file. Existing file will be overwritten
*
* @param dest 目标文件
* @param bean 对象
* @throws IOException IO异常
*/
public static void writeObjectAsXml(File dest, Object bean) throws IOException {
XMLEncoder xmlenc = null;
try {
xmlenc = new XMLEncoder(FileUtil.getOutputStream(dest));
xmlenc.writeObject(bean);
} finally {
// 关闭XMLEncoder会相应关闭OutputStream
IoUtil.close(xmlenc);
}
}
代码示例来源:origin: looly/hutool
/**
* 将可序列化的对象转换为XML写入文件,已经存在的文件将被覆盖<br>
* Writes serializable object to a XML file. Existing file will be overwritten
*
* @param dest 目标文件
* @param bean 对象
* @throws IOException IO异常
*/
public static void writeObjectAsXml(File dest, Object bean) throws IOException {
XMLEncoder xmlenc = null;
try {
xmlenc = new XMLEncoder(FileUtil.getOutputStream(dest));
xmlenc.writeObject(bean);
} finally {
// 关闭XMLEncoder会相应关闭OutputStream
IoUtil.close(xmlenc);
}
}
代码示例来源:origin: looly/hutool
out = FileUtil.getOutputStream(destFile);
return writeBody(out, false, streamProgress);
} catch (IORuntimeException e) {
代码示例来源:origin: looly/hutool
out = FileUtil.getOutputStream(destFile);
return writeBody(out, false, streamProgress);
} catch (IORuntimeException e) {
内容来源于网络,如有侵权,请联系作者删除!