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


Java Files.newReader方法代码示例

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


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

示例1: load

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * Loads a saved dashboard layout.
 *
 * @param saveFile the save file to load
 */
public void load(File saveFile) {
  if (saveFile == null) {
    return;
  }
  try {
    Reader reader = Files.newReader(saveFile, Charset.forName("UTF-8"));

    DashboardData dashboardData = JsonBuilder.forSaveFile().fromJson(reader, DashboardData.class);
    setDashboard(dashboardData.getTabPane());
    Platform.runLater(() -> {
      centerSplitPane.setDividerPositions(dashboardData.getDividerPosition());
    });
  } catch (Exception e) {
    log.log(Level.WARNING, "Couldn't load", e);
    return;
  }

  currentFile = saveFile;
  AppPreferences.getInstance().setSaveFile(currentFile);
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:26,代码来源:MainWindowController.java

示例2: asReader

import com.google.common.io.Files; //导入方法依赖的package包/类
public Reader asReader() {
    File file = asFile();
    try {
        return Files.newReader(asFile(), charset);
    } catch (FileNotFoundException e) {
        throw ResourceExceptions.readMissing(file, e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:FileCollectionBackedTextResource.java

示例3: load

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * Load the cached profiles from disk
 */
public void load()
{
    BufferedReader bufferedreader = null;

    try
    {
        bufferedreader = Files.newReader(this.usercacheFile, Charsets.UTF_8);
        List<PlayerProfileCache.ProfileEntry> list = (List)this.gson.fromJson((Reader)bufferedreader, TYPE);
        this.usernameToProfileEntryMap.clear();
        this.uuidToProfileEntryMap.clear();
        this.gameProfiles.clear();

        for (PlayerProfileCache.ProfileEntry playerprofilecache$profileentry : Lists.reverse(list))
        {
            if (playerprofilecache$profileentry != null)
            {
                this.addEntry(playerprofilecache$profileentry.getGameProfile(), playerprofilecache$profileentry.getExpirationDate());
            }
        }
    }
    catch (FileNotFoundException var9)
    {
        ;
    }
    catch (JsonParseException var10)
    {
        ;
    }
    finally
    {
        IOUtils.closeQuietly((Reader)bufferedreader);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:37,代码来源:PlayerProfileCache.java

示例4: ResourceIndex

import com.google.common.io.Files; //导入方法依赖的package包/类
public ResourceIndex(File assetsFolder, String indexName)
{
    File file1 = new File(assetsFolder, "objects");
    File file2 = new File(assetsFolder, "indexes/" + indexName + ".json");
    BufferedReader bufferedreader = null;

    try
    {
        bufferedreader = Files.newReader(file2, Charsets.UTF_8);
        JsonObject jsonobject = (new JsonParser()).parse((Reader)bufferedreader).getAsJsonObject();
        JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonobject, "objects", (JsonObject)null);

        if (jsonobject1 != null)
        {
            for (Entry<String, JsonElement> entry : jsonobject1.entrySet())
            {
                JsonObject jsonobject2 = (JsonObject)entry.getValue();
                String s = (String)entry.getKey();
                String[] astring = s.split("/", 2);
                String s1 = astring.length == 1 ? astring[0] : astring[0] + ":" + astring[1];
                String s2 = JsonUtils.getString(jsonobject2, "hash");
                File file3 = new File(file1, s2.substring(0, 2) + "/" + s2);
                this.resourceMap.put(s1, file3);
            }
        }
    }
    catch (JsonParseException var20)
    {
        LOGGER.error("Unable to parse resource index file: {}", new Object[] {file2});
    }
    catch (FileNotFoundException var21)
    {
        LOGGER.error("Can\'t find the resource index file: {}", new Object[] {file2});
    }
    finally
    {
        IOUtils.closeQuietly((Reader)bufferedreader);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:40,代码来源:ResourceIndex.java

示例5: load

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * Load the cached profiles from disk
 */
public void load()
{
    BufferedReader bufferedreader = null;

    try
    {
        bufferedreader = Files.newReader(this.usercacheFile, Charsets.UTF_8);
        List<PlayerProfileCache.ProfileEntry> list = (List)this.gson.fromJson((Reader)bufferedreader, TYPE);
        this.usernameToProfileEntryMap.clear();
        this.uuidToProfileEntryMap.clear();
        this.gameProfiles.clear();

        if (list != null)
        {
            for (PlayerProfileCache.ProfileEntry playerprofilecache$profileentry : Lists.reverse(list))
            {
                if (playerprofilecache$profileentry != null)
                {
                    this.addEntry(playerprofilecache$profileentry.getGameProfile(), playerprofilecache$profileentry.getExpirationDate());
                }
            }
        }
    }
    catch (FileNotFoundException var9)
    {
        ;
    }
    catch (JsonParseException var10)
    {
        ;
    }
    finally
    {
        IOUtils.closeQuietly((Reader)bufferedreader);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:40,代码来源:PlayerProfileCache.java

示例6: ResourceIndex

import com.google.common.io.Files; //导入方法依赖的package包/类
public ResourceIndex(File p_i1047_1_, String p_i1047_2_)
{
    if (p_i1047_2_ != null)
    {
        File file1 = new File(p_i1047_1_, "objects");
        File file2 = new File(p_i1047_1_, "indexes/" + p_i1047_2_ + ".json");
        BufferedReader bufferedreader = null;

        try
        {
            bufferedreader = Files.newReader(file2, Charsets.UTF_8);
            JsonObject jsonobject = (new JsonParser()).parse((Reader)bufferedreader).getAsJsonObject();
            JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonobject, "objects", (JsonObject)null);

            if (jsonobject1 != null)
            {
                for (Entry<String, JsonElement> entry : jsonobject1.entrySet())
                {
                    JsonObject jsonobject2 = (JsonObject)entry.getValue();
                    String s = (String)entry.getKey();
                    String[] astring = s.split("/", 2);
                    String s1 = astring.length == 1 ? astring[0] : astring[0] + ":" + astring[1];
                    String s2 = JsonUtils.getString(jsonobject2, "hash");
                    File file3 = new File(file1, s2.substring(0, 2) + "/" + s2);
                    this.resourceMap.put(s1, file3);
                }
            }
        }
        catch (JsonParseException var20)
        {
            logger.error("Unable to parse resource index file: " + file2);
        }
        catch (FileNotFoundException var21)
        {
            logger.error("Can\'t find the resource index file: " + file2);
        }
        finally
        {
            IOUtils.closeQuietly((Reader)bufferedreader);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:43,代码来源:ResourceIndex.java

示例7: asBufferedReader

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * 获取File的BufferedReader
 */
public static BufferedReader asBufferedReader(String fileName) throws FileNotFoundException {
	return Files.newReader(getFileByPath(fileName), Charsets.UTF_8);
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:7,代码来源:FileUtil.java


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