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


Java Files.newWriter方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:28,代码来源:PlayerProfileCache.java

示例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);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:17,代码来源:UserList.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:CSVResultProcessor.java

示例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();
  }
}
 
开发者ID:google,项目名称:rejoiner,代码行数:13,代码来源:LibraryProtoWriter.java

示例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);
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:16,代码来源:MainWindowController.java

示例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);
    }
}
 
开发者ID:KengoTODA,项目名称:sonarqube-rule-xml-generator,代码行数:15,代码来源:RuleXmlGenerator.java

示例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;
}
 
开发者ID:addo37,项目名称:AbilityBots,代码行数:9,代码来源:AbilityBotTest.java

示例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);
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:7,代码来源:FileUtil.java


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