本文整理匯總了Java中com.badlogic.gdx.files.FileHandle.readString方法的典型用法代碼示例。如果您正苦於以下問題:Java FileHandle.readString方法的具體用法?Java FileHandle.readString怎麽用?Java FileHandle.readString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.files.FileHandle
的用法示例。
在下文中一共展示了FileHandle.readString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadState
import com.badlogic.gdx.files.FileHandle; //導入方法依賴的package包/類
public GameState loadState(int slot) {
String saveFileName = getSaveFileName(slot);
FileHandle handle = Gdx.files.internal(saveFileName);
if (handle.exists()) {
try {
String gameStateJSON = handle.readString();
return new Gson().fromJson(gameStateJSON, GameState.class);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
示例2: isGameSaved
import com.badlogic.gdx.files.FileHandle; //導入方法依賴的package包/類
public boolean isGameSaved(int slotIndex) {
String saveFileName = getSaveFileName(slotIndex);
FileHandle handle = Gdx.files.internal(saveFileName);
if (handle.exists()) {
try {
String gameStateJSON = handle.readString();
return new Gson().fromJson(gameStateJSON, GameState.class) != null;
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}
示例3: refresh
import com.badlogic.gdx.files.FileHandle; //導入方法依賴的package包/類
public void refresh() {
FileHandle fileHandle = Gdx.files.absolute(FileLogWriter.file.getAbsolutePath());
String string = "";
try {
string = fileHandle.readString();
} catch (GdxRuntimeException e) {
Log.error("Failed to refresh log menu", e);
}
label.setText(string);
resize(Graphics.GUI_WIDTH, Graphics.GUI_HEIGHT);
}
示例4: prepareCredits
import com.badlogic.gdx.files.FileHandle; //導入方法依賴的package包/類
/**
* Bereitet die Credits für die Anzeige vor.
*
* Zeilen, die mit # Anfangen werden als Überschriften gehandhabt.
* Zeilen, die mit !# Anfangen, werden als Haupt-Überschriften gehandhabt.
*
* @param creditsFile ein FileHandle auf die Datei mit den Credits
*/
private void prepareCredits(FileHandle creditsFile)
{
creditLines.clear();
String credits = creditsFile.readString();
String[] lines = credits.split("\n");
for (String line: lines) {
line = line.trim();
int header = 0;
if (line.startsWith("#"))
{
header = 1;
line = line.substring(1).trim();
}
if (line.startsWith("!#"))
{
header = 2;
line = line.substring(2).trim();
}
creditLines.add(new CreditLine(line, header));
}
}
示例5: loadFromFile
import com.badlogic.gdx.files.FileHandle; //導入方法依賴的package包/類
/**
* load string from given filehandle
* @param handle
* @return
*/
public static String loadFromFile(FileHandle handle) {
String data = null;
data = handle.readString();
return data;
}