cn.hutool.core.io.FileUtil.writeBytes()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(1192)

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

FileUtil.writeBytes介绍

[英]写数据到文件中
[中]写数据到文件中

代码示例

代码示例来源:origin: looly/hutool

/**
 * 写数据到文件中
 * 
 * @param dest 目标文件
 * @param data 数据
 * @return 目标文件
 * @throws IORuntimeException IO异常
 */
public static File writeBytes(byte[] data, File dest) throws IORuntimeException {
  return writeBytes(data, dest, 0, data.length, false);
}

代码示例来源:origin: looly/hutool

/**
 * 写数据到文件中
 * 
 * @param dest 目标文件
 * @param data 数据
 * @return 目标文件
 * @throws IORuntimeException IO异常
 */
public static File writeBytes(byte[] data, File dest) throws IORuntimeException {
  return writeBytes(data, dest, 0, data.length, false);
}

代码示例来源:origin: looly/hutool

/**
 * base64解码
 * 
 * @param base64 被解码的base64字符串
 * @param destFile 目标文件
 * @return 目标文件
 * @since 4.0.9
 */
public static File decodeToFile(String base64, File destFile) {
  return FileUtil.writeBytes(Base64Decoder.decode(base64), destFile);
}

代码示例来源:origin: looly/hutool

/**
 * 写数据到文件中
 * 
 * @param data 数据
 * @param path 目标文件
 * @return 目标文件
 * @throws IORuntimeException IO异常
 */
public static File writeBytes(byte[] data, String path) throws IORuntimeException {
  return writeBytes(data, touch(path));
}

代码示例来源:origin: looly/hutool

/**
 * 写数据到文件中
 * 
 * @param data 数据
 * @param path 目标文件
 * @return 目标文件
 * @throws IORuntimeException IO异常
 */
public static File writeBytes(byte[] data, String path) throws IORuntimeException {
  return writeBytes(data, touch(path));
}

代码示例来源:origin: looly/hutool

/**
 * base64解码
 * 
 * @param base64 被解码的base64字符串
 * @param destFile 目标文件
 * @return 目标文件
 * @since 4.0.9
 */
public static File decodeToFile(String base64, File destFile) {
  return FileUtil.writeBytes(Base64Decoder.decode(base64), destFile);
}

代码示例来源:origin: looly/hutool

/**
 * 将上传的文件写入目标文件<br>
 * 写入后原临时文件会被删除
 * 
 * @return 目标文件
 */
public File write(File destination) throws IOException {
  assertValid();
  
  if (destination.isDirectory() == true) {
    destination = new File(destination, this.header.getFileName());
  }
  if (data != null) {
    FileUtil.writeBytes(data, destination);
    data = null;
  } else {
    if (tempFile != null) {
      FileUtil.move(tempFile, destination, true);
    }
  }
  return destination;
}

代码示例来源:origin: looly/hutool

/**
 * 将上传的文件写入目标文件<br>
 * 写入后原临时文件会被删除
 * 
 * @return 目标文件
 */
public File write(File destination) throws IOException {
  assertValid();
  
  if (destination.isDirectory() == true) {
    destination = new File(destination, this.header.getFileName());
  }
  if (data != null) {
    FileUtil.writeBytes(data, destination);
    data = null;
  } else {
    if (tempFile != null) {
      FileUtil.move(tempFile, destination, true);
    }
  }
  return destination;
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 写数据到文件中
 * 
 * @param dest 目标文件
 * @param data 数据
 * @return 目标文件
 * @throws IORuntimeException IO异常
 */
public static File writeBytes(byte[] data, File dest) throws IORuntimeException {
  return writeBytes(data, dest, 0, data.length, false);
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * base64解码
 * 
 * @param base64 被解码的base64字符串
 * @param destFile 目标文件
 * @return 目标文件
 * @since 4.0.9
 */
public static File decodeToFile(String base64, File destFile) {
  return FileUtil.writeBytes(Base64Decoder.decode(base64), destFile);
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 写数据到文件中
 * 
 * @param data 数据
 * @param path 目标文件
 * @return 目标文件
 * @throws IORuntimeException IO异常
 */
public static File writeBytes(byte[] data, String path) throws IORuntimeException {
  return writeBytes(data, touch(path));
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 将上传的文件写入目标文件<br>
 * 写入后原临时文件会被删除
 * 
 * @return 目标文件
 */
public File write(File destination) throws IOException {
  assertValid();
  
  if (destination.isDirectory() == true) {
    destination = new File(destination, this.header.getFileName());
  }
  if (data != null) {
    FileUtil.writeBytes(data, destination);
    data = null;
  } else {
    if (tempFile != null) {
      FileUtil.move(tempFile, destination, true);
    }
  }
  return destination;
}

相关文章

微信公众号

最新文章

更多