當前位置: 首頁>>代碼示例>>Java>>正文


Java FileHandle.reader方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.files.FileHandle.reader方法的典型用法代碼示例。如果您正苦於以下問題:Java FileHandle.reader方法的具體用法?Java FileHandle.reader怎麽用?Java FileHandle.reader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.files.FileHandle的用法示例。


在下文中一共展示了FileHandle.reader方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: read

import com.badlogic.gdx.files.FileHandle; //導入方法依賴的package包/類
public static boolean read() {
	FileHandle fileHandle = Compatibility.get().getBaseFolder().child("settings.json");

	try {
		Reader reader = fileHandle.reader();
		JsonObject json = Json.parse(reader).asObject();
		reader.close();

		for (Member member : json) {
			Setting setting = set.settings.get(member.getName());
			setting.readJson(member.getValue());
		}

		return true;
	} catch (Exception e) {
		Log.error("Failed to read settings", e);
		fileHandle.delete();
		return false;
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:21,代碼來源:Settings.java

示例2: read

import com.badlogic.gdx.files.FileHandle; //導入方法依賴的package包/類
public static boolean read() {
  FileHandle fileHandle = Compatibility.get().getBaseFolder().child("settings.json");
  
  try {
    Reader reader = fileHandle.reader();
    JsonObject json = Json.parse(reader).asObject();
    reader.close();

    for (Member member : json) {
      Setting setting = settings.get(member.getName());
      setting.readJson(member.getValue());
    }
    
    return true;
  } catch (Exception e) {
    Log.error("Failed to read settings", e);
    fileHandle.delete();
    return false;
  }
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:21,代碼來源:Settings.java

示例3: Translator

import com.badlogic.gdx.files.FileHandle; //導入方法依賴的package包/類
public Translator(String language)
{
    this.language = language;
    translation = new HashMap<>();
    // THIS FILE MUST BE UTF8 WITHOUT BOM
    FileHandle file = Gdx.files.internal("translation/" + language + ".txt");
    BufferedReader reader = new BufferedReader(file.reader("UTF8"));
    ArrayList<String> lines = new ArrayList<>();
    try
    {
        String line = reader.readLine();
        while (line != null)
        {
            // 過濾掉註解#
            if (!line.trim().equals("") && !line.trim().startsWith("#"))
            {
                lines.add(line.trim());
            }
            line = reader.readLine();
        }
        reader.close();
    }
    catch (IOException ioe)
    {
    }

    // 檢查:翻譯ㄧ定要成對出現
    if (lines.size() % 2 != 0)
    {
        Gdx.app.log("Translator", "ERROR READING FILE" + " translation/" + language + ".txt", new Exception("Lines of original texts and translated texts in the translation file do not match."));
    }

    for (int i = 0; i < lines.size(); i += 2)
    {
        String trans = lines.get(i + 1);
        Gdx.app.log("Translator", lines.get(i).toLowerCase() + " => 加入翻譯 => " + trans + "\n");
        translation.put(lines.get(i).toLowerCase(), trans);
    }
}
 
開發者ID:kurtyu,項目名稱:PixelDungeonTC,代碼行數:40,代碼來源:Translator.java


注:本文中的com.badlogic.gdx.files.FileHandle.reader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。