本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}