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