java.io.BufferedWriter.append()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(382)

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

BufferedWriter.append介绍

暂无

代码示例

代码示例来源:origin: pxb1988/dex2jar

@Override
public void s(String s) {
  try {
    for (int i = 0; i < this.i; i++) {
      writer.append(indent);
    }
    writer.append(s);
    writer.newLine();
  } catch (IOException ex) {
    throw new RuntimeException(ex);
  }
}

代码示例来源:origin: elasticjob/elastic-job-lite

private void outputMessage(final BufferedWriter outputWriter, final String msg) throws IOException {
  outputWriter.append(msg);
  outputWriter.flush();
}

代码示例来源:origin: pxb1988/dex2jar

@Override
  public void s(String format, Object... arg) {
    try {
      for (int i = 0; i < this.i; i++) {
        writer.append(indent);
      }
      writer.append(String.format(format, arg));
      writer.newLine();
    } catch (IOException ex) {
      throw new RuntimeException(ex);
    }
  }
}

代码示例来源:origin: springside/springside4

/**
 * 简单写入String到File.
 */
public static void write(final CharSequence data, final File file) throws IOException {
  Validate.notNull(file);
  Validate.notNull(data);
  try (BufferedWriter writer = Files.newBufferedWriter(file.toPath(), Charsets.UTF_8)) {
    writer.append(data);
  }
}

代码示例来源:origin: springside/springside4

/**
 * 追加String到File.
 */
public static void append(final CharSequence data, final File file) throws IOException {
  Validate.notNull(file);
  Validate.notNull(data);
  try (BufferedWriter writer = Files.newBufferedWriter(file.toPath(), Charsets.UTF_8,
      StandardOpenOption.APPEND)) {
    writer.append(data);
  }
}

代码示例来源:origin: graphhopper/graphhopper

public static void saveProperties(Map<String, String> map, Writer tmpWriter) throws IOException {
  BufferedWriter writer = new BufferedWriter(tmpWriter);
  try {
    for (Entry<String, String> e : map.entrySet()) {
      writer.append(e.getKey());
      writer.append('=');
      writer.append(e.getValue());
      writer.append('\n');
    }
  } finally {
    writer.close();
  }
}

代码示例来源:origin: SonarSource/sonarqube

private void writeSystemProps(BufferedWriter fileWriter) throws IOException {
 fileWriter.write("System properties:\n");
 Properties sysProps = system.properties();
 for (String prop : new TreeSet<>(sysProps.stringPropertyNames())) {
  if (prop.startsWith(SONAR_PROP_PREFIX)) {
   continue;
  }
  fileWriter.append(String.format(KEY_VALUE_FORMAT, prop, sysProps.getProperty(prop))).append('\n');
 }
}

代码示例来源:origin: apache/kylin

private void saveToFile(String fileName, String contents) throws IOException {
    File parentDir = new File(fileName).getParentFile();
    if (!parentDir.exists()) {
      parentDir.mkdirs();
    }

    try (BufferedWriter bufferedWriter = new BufferedWriter(
        new OutputStreamWriter(new FileOutputStream(fileName), StandardCharsets.UTF_8))) {
      bufferedWriter.append(contents);
    }
  }
}

代码示例来源:origin: FudanNLP/fnlp

/**
 * 将字符串写到文件
 * @param path
 * @param str
 * @throws IOException
 */
public static void write(String path, String str) throws IOException {
  BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(
      path), "utf8"));
  out.append(str);
  out.close();        
}
public static void write(String path, Serializable o) {

代码示例来源:origin: androidannotations/androidannotations

private boolean listWindows(Socket client) {
  boolean result = true;
  BufferedWriter out = null;
  try {
    mWindowsLock.readLock().lock();
    OutputStream clientStream = client.getOutputStream();
    out = new BufferedWriter(new OutputStreamWriter(clientStream), 8 * 1024);
    for (Entry<View, String> entry : mWindows.entrySet()) {
      out.write(Integer.toHexString(System.identityHashCode(entry.getKey())));
      out.write(' ');
      out.append(entry.getValue());
      out.write('\n');
    }
    out.write("DONE.\n");
    out.flush();
  } catch (Exception e) {
    result = false;
  } finally {
    mWindowsLock.readLock().unlock();
    if (out != null) {
      try {
        out.close();
      } catch (IOException e) {
        result = false;
      }
    }
  }
  return result;
}

代码示例来源:origin: pxb1988/dex2jar

private void dumpMethod(BufferedWriter writer, DexMethodNode dexMethodNode, Exception ex) throws IOException {
  writer.append(dexMethodNode.method.toString());
  writer.newLine();
  writer.flush();
  ex.printStackTrace(new PrintWriter(writer, true));
  writer.newLine();
  new BaksmaliDumper().baksmaliMethod(dexMethodNode, writer);
  writer.flush();
}

代码示例来源:origin: apache/geode

public static void storeClassesAndVariables(List<ClassAndVariables> cams, File file)
   throws IOException {
  FileWriter fw = new FileWriter(file);
  BufferedWriter out = new BufferedWriter(fw);
  for (ClassAndVariables entry : cams) {
   out.append(ClassAndVariableDetails.convertForStoring(entry));
   out.newLine();
  }
  out.flush();
  out.close();
 }
}

代码示例来源:origin: apache/geode

public static void storeClassesAndMethods(List<ClassAndMethods> cams, File file)
  throws IOException {
 FileWriter fw = new FileWriter(file);
 BufferedWriter out = new BufferedWriter(fw);
 for (ClassAndMethods entry : cams) {
  out.append(ClassAndMethodDetails.convertForStoring(entry));
  out.newLine();
 }
 out.flush();
 out.close();
}

代码示例来源:origin: SonarSource/sonarqube

private void writeEnvVariables(BufferedWriter fileWriter) throws IOException {
 fileWriter.append("Environment variables:\n");
 Map<String, String> envVariables = system.envVariables();
 new TreeSet<>(envVariables.keySet())
  .forEach(envKey -> {
   try {
    String envValue = isSensitiveEnvVariable(envKey) ? "******" : envVariables.get(envKey);
    fileWriter.append(String.format(KEY_VALUE_FORMAT, envKey, envValue)).append('\n');
   } catch (IOException e) {
    throw new IllegalStateException(e);
   }
  });
}

代码示例来源:origin: org.codehaus.groovy/groovy

private void writeNode(String key, String space, int tab, ConfigObject value, BufferedWriter out) throws IOException {
  key = KEYWORDS.contains(key) ? InvokerHelper.inspect(key) : key;
  out.append(space).append(key).append(" {");
  out.newLine();
  writeConfig("", value, out, tab + 1, true);
  out.append(space).append('}');
  out.newLine();
}

代码示例来源:origin: SonarSource/sonarqube

private void writeGlobalSettings(BufferedWriter fileWriter) throws IOException {
 fileWriter.append("Global server settings:\n");
 Map<String, String> props = globalServerSettings.properties();
 for (String prop : new TreeSet<>(props.keySet())) {
  dumpPropIfNotSensitive(fileWriter, prop, props.get(prop));
 }
}

代码示例来源:origin: SonarSource/sonarqube

private static void dumpPropIfNotSensitive(BufferedWriter fileWriter, String prop, String value) throws IOException {
 fileWriter.append(String.format(KEY_VALUE_FORMAT, prop, isSensitiveProperty(prop) ? "******" : StringUtils.abbreviate(value, MAX_WIDTH))).append('\n');
}

代码示例来源:origin: SonarSource/sonarqube

private void writeProjectSettings(BufferedWriter fileWriter) throws IOException {
 fileWriter.append("Project server settings:\n");
 Map<String, String> props = projectServerSettings.properties();
 for (String prop : new TreeSet<>(props.keySet())) {
  dumpPropIfNotSensitive(fileWriter, prop, props.get(prop));
 }
 fileWriter.append("Project scanner properties:\n");
 writeScannerProps(fileWriter, hierarchy.root().properties());
}

代码示例来源:origin: SonarSource/sonarqube

private void writePlugins(BufferedWriter fileWriter) throws IOException {
 fileWriter.write("SonarQube plugins:\n");
 for (PluginInfo p : pluginRepo.getPluginInfos()) {
  fileWriter.append(String.format("  - %s %s (%s)", p.getName(), p.getVersion(), p.getKey())).append('\n');
 }
}

代码示例来源:origin: SonarSource/sonarqube

private void writeModulesSettings(BufferedWriter fileWriter) throws IOException {
 for (DefaultInputModule module : store.allModules()) {
  if (module.equals(hierarchy.root())) {
   continue;
  }
  Map<String, String> moduleSpecificProps = collectModuleSpecificProps(module);
  fileWriter.append(String.format("Scanner properties of module: %s", module.key())).append('\n');
  writeScannerProps(fileWriter, moduleSpecificProps);
 }
}

相关文章