當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。