本文整理汇总了Java中com.google.common.io.Files.newWriter方法的典型用法代码示例。如果您正苦于以下问题:Java Files.newWriter方法的具体用法?Java Files.newWriter怎么用?Java Files.newWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.io.Files
的用法示例。
在下文中一共展示了Files.newWriter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import com.google.common.io.Files; //导入方法依赖的package包/类
/**
* Save the cached profiles to disk
*/
public void save()
{
String s = this.gson.toJson((Object)this.getEntriesWithLimit(1000));
BufferedWriter bufferedwriter = null;
try
{
bufferedwriter = Files.newWriter(this.usercacheFile, Charsets.UTF_8);
bufferedwriter.write(s);
return;
}
catch (FileNotFoundException var8)
{
;
}
catch (IOException var9)
{
return;
}
finally
{
IOUtils.closeQuietly((Writer)bufferedwriter);
}
}
示例2: writeChanges
import com.google.common.io.Files; //导入方法依赖的package包/类
public void writeChanges() throws IOException
{
Collection<V> collection = this.values.values();
String s = this.gson.toJson((Object)collection);
BufferedWriter bufferedwriter = null;
try
{
bufferedwriter = Files.newWriter(this.saveFile, Charsets.UTF_8);
bufferedwriter.write(s);
}
finally
{
IOUtils.closeQuietly((Writer)bufferedwriter);
}
}
示例3: CSVResultProcessor
import com.google.common.io.Files; //导入方法依赖的package包/类
public CSVResultProcessor(File resultFile) {
this.resultFile = resultFile;
this.workFile = new File(resultFile.getPath() + ".tmp");
try {
writer = new CSVWriter(Files.newWriter(resultFile, Charset.forName("UTF-8")));
addLabels();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例4: main
import com.google.common.io.Files; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
if (args.length == 0) {
throw new RuntimeException("output path required");
}
String proto = SchemaToProto.toProto(LibrarySchema.SCHEMA);
BufferedWriter writer = Files.newWriter(new File(args[0]), Charsets.UTF_8);
try {
writer.write(proto);
} finally {
writer.close();
}
}
示例5: saveFile
import com.google.common.io.Files; //导入方法依赖的package包/类
private void saveFile(File selected) {
try {
Writer writer = Files.newWriter(selected, Charset.forName("UTF-8"));
DashboardData dashboardData = new DashboardData(centerSplitPane.getDividerPositions()[0], dashboard);
JsonBuilder.forSaveFile().toJson(dashboardData, writer);
writer.flush();
} catch (Exception e) {
log.log(Level.WARNING, "Couldn't save", e);
return;
}
currentFile = selected;
AppPreferences.getInstance().setSaveFile(currentFile);
}
示例6: writePatterns
import com.google.common.io.Files; //导入方法依赖的package包/类
private void writePatterns(List<Node> findbugsAbstract, List<Node> bugPatterns, File output, String[] tags) throws IOException {
BufferedWriter writer = Files.newWriter(output, Charsets.UTF_8);
boolean threw = true;
try {
writer.write("<rules>\n");
for (Node bugPattern : bugPatterns) {
writeBugPattern(bugPattern, findbugsAbstract, writer, tags);
}
writer.write("</rules>\n");
threw = false;
} finally {
Closeables.close(writer, threw);
}
}
示例7: createBackupFile
import com.google.common.io.Files; //导入方法依赖的package包/类
private java.io.File createBackupFile(Object backup) throws IOException {
java.io.File backupFile = new java.io.File(TEST);
BufferedWriter writer = Files.newWriter(backupFile, Charset.defaultCharset());
writer.write(backup.toString());
writer.flush();
writer.close();
return backupFile;
}
示例8: asBufferedWriter
import com.google.common.io.Files; //导入方法依赖的package包/类
/**
* 获取File的BufferedWriter
*/
public static BufferedWriter asBufferedWriter(String fileName) throws FileNotFoundException {
return Files.newWriter(getFileByPath(fileName), Charsets.UTF_8);
}