当前位置: 首页>>代码示例>>Java>>正文


Java CharSink.writeLines方法代码示例

本文整理汇总了Java中com.google.common.io.CharSink.writeLines方法的典型用法代码示例。如果您正苦于以下问题:Java CharSink.writeLines方法的具体用法?Java CharSink.writeLines怎么用?Java CharSink.writeLines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.io.CharSink的用法示例。


在下文中一共展示了CharSink.writeLines方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: storeProperties

import com.google.common.io.CharSink; //导入方法依赖的package包/类
/**
 * 
 * @param path
 * @param p
 * @param needEncrypts
 *          암호화 할 키 값 조건
 */
public static void storeProperties(String path, Properties p, Comparable<String> needEncrypts) {

	final EncryptedProperties ep = encryptedProperties(p);

	Iterable<String> lines = Iterables.transform(ep.stringPropertyNames(), k -> {
		String v = ep.getProperty(k);
		if (0 == needEncrypts.compareTo(k))
			v = Secures.encrypts(v);
		return k + "=" + v;
	});

	CharSink sink = Files.asCharSink(Paths.get(path).toFile(), Charsets.UTF_8);
	try {
		sink.writeLines(lines);
	} catch (Exception e) {
		log.error("fail to store properties cause: {}", e.getMessage());
		log.debug("detail cause", e);
	}
}
 
开发者ID:dohbot,项目名称:knives,代码行数:27,代码来源:Configs.java

示例2: whenWriteMultipleLinesUsingCharSink_thenWritten

import com.google.common.io.CharSink; //导入方法依赖的package包/类
@Test
public void whenWriteMultipleLinesUsingCharSink_thenWritten() throws IOException {
    final List<String> names = Lists.newArrayList("John", "Jane", "Adam", "Tom");
    final File file = new File("src/test/resources/test.out");
    final CharSink sink = Files.asCharSink(file, Charsets.UTF_8);

    sink.writeLines(names, " ");

    final String result = Files.toString(file, Charsets.UTF_8);
    final String expectedValue = Joiner.on(" ").join(names);
    assertEquals(expectedValue, result.trim());

}
 
开发者ID:wenzhucjy,项目名称:GeneralUtils,代码行数:14,代码来源:GuavaIOTest.java

示例3: write

import com.google.common.io.CharSink; //导入方法依赖的package包/类
@Override
public void write(ResponseLinking responseLinking, CharSink sink) throws IOException {
  final List<String> lines = Lists.newArrayList();
  for (final ResponseSet responseSet : responseLinking.responseSets()) {
    lines.add(renderLine(responseSet, responseLinking));
  }

  // incompletes last
  lines.add("INCOMPLETE\t" + Joiner.on("\t").join(
      transform(responseLinking.incompleteResponses(), ResponseFunctions.uniqueIdentifier())));

  sink.writeLines(lines, "\n");
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:14,代码来源:LinkingStoreSource.java

示例4: writeEDLMentions

import com.google.common.io.CharSink; //导入方法依赖的package包/类
/**
 * Writes out the specified {@link EDLMention}s. If a {@link #defaultKbId} was not specified,
 * an exception will be thrown if any EDL mentions have an absent KB ID.
 */
public void writeEDLMentions(Iterable<EDLMention> edlMentions, CharSink sink) throws IOException {
  final List<String> lines = Lists.newArrayList();

  for (final EDLMention edlMention : edlMentions) {
    lines.add(toLine(edlMention));
  }

  sink.writeLines(lines, "\n");
}
 
开发者ID:BBN-E,项目名称:bue-common-open,代码行数:14,代码来源:EDLWriter.java

示例5: writeLines

import com.google.common.io.CharSink; //导入方法依赖的package包/类
public static  void writeLines(String fileName,List<String> list,Charset charset) throws IOException {
    CharSink cs = Files.asCharSink(new File(fileName), charset);
    list = PojoUtil.avoidEmptyList(list);
    cs.writeLines(list);
}
 
开发者ID:zhengjunbase,项目名称:codehelper.generator,代码行数:6,代码来源:IOUtils.java

示例6: writeUnixLines

import com.google.common.io.CharSink; //导入方法依赖的package包/类
/**
 * Generally we want to avoid {@link CharSink#writeLines(Iterable)} because it uses the OS default
 * line separator, but our code always works with Unix line endings regardless of platform. This
 * is just like {@link CharSink#writeLines(Iterable)}, but always uses Unix endings.
 */
public static void writeUnixLines(Iterable<? extends CharSequence> lines, CharSink sink)
    throws IOException {
  sink.writeLines(lines, "\n");
}
 
开发者ID:BBN-E,项目名称:bue-common-open,代码行数:10,代码来源:FileUtils.java


注:本文中的com.google.common.io.CharSink.writeLines方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。