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

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

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

FileUtil.getPrintWriter介绍

[英]获得一个打印写入对象,可以有print
[中]获得一个打印写入对象,可以有打印

代码示例

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

/**
 * 持久化当前设置,会覆盖掉之前的设置<br>
 * 持久化会不会保留之前的分组
 * 
 * @param absolutePath 设置文件的绝对路径
 */
public void store(String absolutePath) {
  PrintWriter writer = null;
  try {
    writer = FileUtil.getPrintWriter(absolutePath, charset, false);
    store(writer);
  } catch (IOException e) {
    throw new IORuntimeException(e, "Store Setting to [{}] error!", absolutePath);
  } finally {
    IoUtil.close(writer);
  }
}

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

/**
 * 持久化当前设置,会覆盖掉之前的设置<br>
 * 持久化会不会保留之前的分组
 * 
 * @param absolutePath 设置文件的绝对路径
 */
public void store(String absolutePath) {
  PrintWriter writer = null;
  try {
    writer = FileUtil.getPrintWriter(absolutePath, charset, false);
    store(writer);
  } catch (IOException e) {
    throw new IORuntimeException(e, "Store Setting to [{}] error!", absolutePath);
  } finally {
    IoUtil.close(writer);
  }
}

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

/**
 * 生成文件
 * 
 * @param template 模板
 * @param context 模板上下文
 * @param destPath 目标路径(绝对)
 */
public static void toFile(Template template, VelocityContext context, String destPath) {
  PrintWriter writer = null;
  try {
    writer = FileUtil.getPrintWriter(destPath, Velocity.getProperty(Velocity.OUTPUT_ENCODING).toString(), false);
    merge(template, context, writer);
  } catch (IORuntimeException e) {
    throw new UtilException(e, "Write Velocity content to [{}] error!", destPath);
  } finally {
    IoUtil.close(writer);
  }
}

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

/**
 * 生成文件
 * 
 * @param template 模板
 * @param context 模板上下文
 * @param destPath 目标路径(绝对)
 */
public static void toFile(Template template, VelocityContext context, String destPath) {
  PrintWriter writer = null;
  try {
    writer = FileUtil.getPrintWriter(destPath, Velocity.getProperty(Velocity.OUTPUT_ENCODING).toString(), false);
    merge(template, context, writer);
  } catch (IORuntimeException e) {
    throw new UtilException(e, "Write Velocity content to [{}] error!", destPath);
  } finally {
    IoUtil.close(writer);
  }
}

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

/**
 * 持久化当前设置,会覆盖掉之前的设置<br>
 * 持久化会不会保留之前的分组
 * 
 * @param absolutePath 设置文件的绝对路径
 */
public void store(String absolutePath) {
  PrintWriter writer = null;
  try {
    writer = FileUtil.getPrintWriter(absolutePath, charset, false);
    store(writer);
  } catch (IOException e) {
    throw new IORuntimeException(e, "Store Setting to [{}] error!", absolutePath);
  } finally {
    IoUtil.close(writer);
  }
}

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

/**
 * 持久化当前设置,会覆盖掉之前的设置<br>
 * 持久化会不会保留之前的分组
 * 
 * @param absolutePath 设置文件的绝对路径
 */
public void store(String absolutePath) {
  PrintWriter writer = null;
  try {
    writer = FileUtil.getPrintWriter(absolutePath, charset, false);
    store(writer);
  } catch (IOException e) {
    throw new IORuntimeException(e, "Store Setting to [{}] error!", absolutePath);
  } finally {
    IoUtil.close(writer);
  }
}

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

/**
 * 生成文件
 * 
 * @param template 模板
 * @param context 模板上下文
 * @param destPath 目标路径(绝对)
 */
public static void toFile(Template template, VelocityContext context, String destPath) {
  PrintWriter writer = null;
  try {
    writer = FileUtil.getPrintWriter(destPath, Velocity.getProperty(Velocity.OUTPUT_ENCODING).toString(), false);
    merge(template, context, writer);
  } catch (IORuntimeException e) {
    throw new UtilException(e, "Write Velocity content to [{}] error!", destPath);
  } finally {
    IoUtil.close(writer);
  }
}

相关文章

微信公众号

最新文章

更多