java.io.FileWriter.getEncoding()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(219)

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

FileWriter.getEncoding介绍

暂无

代码示例

代码示例来源:origin: bobbylight/RSyntaxTextArea

/**
 * Returns the default encoding for this operating system.
 *
 * @return The default encoding.
 */
private static String getDefaultEncoding() {
  // NOTE:  The "file.encoding" system property is not guaranteed to be
  // set by the spec, so we cannot rely on it.
  String encoding = Charset.defaultCharset().name();
  if (encoding==null) {
    try {
      File f = File.createTempFile("rsta", null);
      FileWriter w = new FileWriter(f);
      encoding = w.getEncoding();
      w.close();
      f.deleteOnExit();//delete();  Keep FindBugs happy
    } catch (IOException ioe) {
      encoding = "US-ASCII";
    }
  }
  return encoding;
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-editor

/**
 * Returns the default encoding for this operating system.
 *
 * @return The default encoding.
 */
private static final String getDefaultEncoding() {
  // TODO: Change to "Charset.defaultCharset().name()" when 1.4 support
  // is no longer needed.
  // NOTE:  The "file.encoding" property is not guaranteed to be set by
  // the spec, so we cannot rely on it.
  String encoding = System.getProperty("file.encoding");
  if (encoding==null) {
    try {
      File f = File.createTempFile("rsta", null);
      FileWriter w = new FileWriter(f);
      encoding = w.getEncoding();
      w.close();
      f.deleteOnExit();//delete();  Keep FindBugs happy
    } catch (IOException ioe) {
      encoding = "US-ASCII";
    }
  }
  return encoding;
}

代码示例来源:origin: com.fifesoft/rsyntaxtextarea

/**
 * Returns the default encoding for this operating system.
 *
 * @return The default encoding.
 */
private static String getDefaultEncoding() {
  // NOTE:  The "file.encoding" system property is not guaranteed to be
  // set by the spec, so we cannot rely on it.
  String encoding = Charset.defaultCharset().name();
  if (encoding==null) {
    try {
      File f = File.createTempFile("rsta", null);
      FileWriter w = new FileWriter(f);
      encoding = w.getEncoding();
      w.close();
      f.deleteOnExit();//delete();  Keep FindBugs happy
    } catch (IOException ioe) {
      encoding = "US-ASCII";
    }
  }
  return encoding;
}

代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea

/**
 * Returns the default encoding for this operating system.
 *
 * @return The default encoding.
 */
private static final String getDefaultEncoding() {
  // TODO: Change to "Charset.defaultCharset().name()" when 1.4 support
  // is no longer needed.
  // NOTE:  The "file.encoding" property is not guaranteed to be set by
  // the spec, so we cannot rely on it.
  String encoding = System.getProperty("file.encoding");
  if (encoding==null) {
    try {
      File f = File.createTempFile("rsta", null);
      FileWriter w = new FileWriter(f);
      encoding = w.getEncoding();
      w.close();
      f.deleteOnExit();//delete();  Keep FindBugs happy
    } catch (IOException ioe) {
      encoding = "US-ASCII";
    }
  }
  return encoding;
}

代码示例来源:origin: EvoSuite/evosuite

@Override
public String getEncoding() {
  if(!MockFramework.isEnabled()){
    return super.getEncoding();
  }
  return stream.getEncoding();
}

相关文章