本文整理了Java中com.badlogic.gdx.Files.local()
方法的一些代码示例,展示了Files.local()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Files.local()
方法的具体详情如下:
包路径:com.badlogic.gdx.Files
类名称:Files
方法名:local
[英]Convenience method that returns a FileType#Local file handle.
[中]返回文件类型#本地文件句柄的便利方法。
代码示例来源:origin: libgdx/libgdx
@Override
public FileHandle resolve (String fileName) {
return Gdx.files.local(fileName);
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public FileHandle resolve (String fileName) {
return Gdx.files.local(fileName);
}
}
代码示例来源:origin: libgdx/libgdx
out = new BufferedWriter(new OutputStreamWriter(Gdx.files.local("test.txt").write(false)));
out.write("test");
message += "Write local success\n";
InputStream in = Gdx.files.local("test.txt").read();
StreamUtils.closeQuietly(in);
message += "Open local success\n";
in = new BufferedReader(new InputStreamReader(Gdx.files.local("test.txt").read()));
if (!in.readLine().equals("test"))
message += "Read result wrong\n";
byte[] testBytes = Gdx.files.local("test.txt").readBytes();
if (Arrays.equals("test".getBytes(), testBytes))
message += "Read into byte array success\n";
if (!Gdx.files.local("test.txt").delete()) message += "Couldn't delete localstorage/test.txt";
代码示例来源:origin: libgdx/libgdx
BitmapFontWriter.writeFont(generatedFont.getData(), new String[] {"bitmapWrittenFont.png"}, Gdx.files.local("bitmapWrittenFont.fnt"), info, 512, 512);
BitmapFontWriter.writePixmaps(param.packer.getPages(), Gdx.files.local(""), "bitmapWrittenFont");
final float xHeight = generatedFont.getXHeight();
loadedFont = new BitmapFont(Gdx.files.local("bitmapWrittenFont.fnt"));
代码示例来源:origin: libgdx/libgdx
private void testLocal () throws IOException {
String path = "meow";
FileHandle handle = Gdx.files.local(path);
handle.delete();
if (handle.exists()) fail();
if (!handle.exists()) fail();
if (handle.length() != 3) fail();
FileHandle copy = Gdx.files.local(path + "-copy");
copy.delete();
if (copy.exists()) fail();
if (!copy.exists()) fail();
if (copy.length() != 3) fail();
FileHandle move = Gdx.files.local(path + "-move");
move.delete();
if (move.exists()) fail();
代码示例来源:origin: libgdx/libgdx
PixmapPackerIO.SaveParameters saveParameters = new PixmapPackerIO.SaveParameters();
saveParameters.format = PixmapPackerIO.ImageFormat.PNG;
pixmapPackerIO.save(Gdx.files.local("pixmapPackerTest.atlas"), packer, saveParameters);
} catch (IOException e) {
e.printStackTrace();
TextureAtlas loaded = new TextureAtlas(Gdx.files.local("pixmapPackerTest.atlas"));
for (int i = 0; i < loaded.getRegions().size; i++) {
final TextureAtlas.AtlasRegion atlasRegion = loaded.getRegions().get(i);
代码示例来源:origin: com.badlogicgames.gdx/gdx
@Override
public FileHandle resolve (String fileName) {
return Gdx.files.local(fileName);
}
}
代码示例来源:origin: LonamiWebs/Klooni1010
static boolean hasSavedData() {
return Gdx.files.local(SAVE_DAT_FILENAME).exists();
}
代码示例来源:origin: dingjibang/GDX-RPG
/**
* 从路径中读取对象<i>(可能为null)</i>
*/
public static Serializable load(String fileName) {
try {
Object o;
FileInputStream fis = new FileInputStream(Gdx.files.local(fileName).file());
ObjectInputStream ois = new ObjectInputStream(fis);
o = ois.readObject();
ois.close();
return (Serializable)o;
} catch (Exception e) {
return null;
}
}
代码示例来源:origin: dingjibang/GDX-RPG
/**
* 将一个对象存储到硬盘上
*/
public static void save(Serializable o, String filePath){
try {
Gdx.files.local(Path.SAVE).mkdirs();
java.io.File file = Gdx.files.local(filePath).file();
if(!file.exists()){
file.createNewFile();
}
FileOutputStream fos = new FileOutputStream(file);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(o);
oos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
public FileHandle getUserFolder() {
FileHandle file = null;
if (Gdx.app.getType() == ApplicationType.Desktop || Gdx.app.getType() == ApplicationType.Applet) {
String dir = Config.getProperty(Config.TITLE_PROP, DESKTOP_PREFS_DIR);
dir.replace(" ", "");
StringBuilder sb = new StringBuilder(".");
if (System.getProperty("os.name").toLowerCase().contains("mac")
&& System.getenv("HOME").contains("Containers")) {
file = Gdx.files.absolute(System.getenv("HOME") + "/" + sb.append(dir).toString());
} else {
file = Gdx.files.external(sb.append(dir).toString());
}
} else {
file = Gdx.files.local(NOT_DESKTOP_PREFS_DIR);
}
return file;
}
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
public FileHandle getUserFile(String filename) {
FileHandle file = null;
if (Gdx.app.getType() == ApplicationType.Desktop || Gdx.app.getType() == ApplicationType.Applet) {
String dir = Config.getProperty(Config.TITLE_PROP, DESKTOP_PREFS_DIR);
dir.replace(" ", "");
StringBuilder sb = new StringBuilder();
sb.append(".").append(dir).append("/").append(filename);
if (System.getProperty("os.name").toLowerCase().contains("mac")
&& System.getenv("HOME").contains("Containers")) {
file = Gdx.files.absolute(System.getenv("HOME") + "/" + sb.toString());
} else {
file = Gdx.files.external(sb.toString());
}
} else {
file = Gdx.files.local(NOT_DESKTOP_PREFS_DIR + filename);
}
return file;
}
代码示例来源:origin: moribitotech/MTX
private static ArrayList<String> getUpdatedTextInfo(String strFile,
int lineNumber, String newValue) {
ArrayList<String> lineByLineTextList = new ArrayList<String>();
FileHandle file = Gdx.files.local(strFile);
BufferedReader reader = new BufferedReader(new InputStreamReader(
file.read()));
String currentLine = null;
int counter = 0;
try {
while ((currentLine = reader.readLine()) != null) {
if (counter == lineNumber) {
MtxLogger.log(logActive, true, logTag,
"WRITE EXISTING LINE: OLD: " + currentLine
+ " - NEW: " + newValue);
lineByLineTextList.add(newValue);
} else {
lineByLineTextList.add(currentLine);
}
counter++;
}
reader.close();
} catch (IOException e) {
}
return lineByLineTextList;
}
代码示例来源:origin: LonamiWebs/Klooni1010
private void deleteSave() {
final FileHandle handle = Gdx.files.local(SAVE_DAT_FILENAME);
if (handle.exists())
handle.delete();
}
代码示例来源:origin: LonamiWebs/Klooni1010
private void save() {
// Only save if the game is not over and the game mode is not the time mode. It
// makes no sense to save the time game mode since it's supposed to be something quick.
// Don't save either if the score is 0, which means the player did nothing.
if (gameOverDone || gameMode != GAME_MODE_SCORE || scorer.getCurrentScore() == 0)
return;
final FileHandle handle = Gdx.files.local(SAVE_DAT_FILENAME);
try {
BinSerializer.serialize(this, handle.write(false));
} catch (IOException e) {
// Should never happen but what else could be done if the game wasn't saved?
e.printStackTrace();
}
}
代码示例来源:origin: kotcrab/vis-ui
public FileHandle toFileHandle () {
switch (type) {
case Absolute:
return Gdx.files.absolute(path);
case Classpath:
return Gdx.files.classpath(path);
case External:
return Gdx.files.external(path);
case Internal:
return Gdx.files.internal(path);
case Local:
return Gdx.files.local(path);
default:
throw new IllegalStateException("Unknown file type!");
}
}
}
代码示例来源:origin: org.mini2Dx/mini2Dx-core
return Gdx.files.classpath(components[1]);
case "local":
return Gdx.files.local(components[1]);
default:
throw new MdxException("Invalid URI specified. Options are internal://, external://, absolute://, classpath://, local://");
代码示例来源:origin: LonamiWebs/Klooni1010
private boolean tryLoad() {
final FileHandle handle = Gdx.files.local(SAVE_DAT_FILENAME);
if (handle.exists()) {
try {
BinSerializer.deserialize(this, handle.read());
// No cheating! We need to load the previous money
// or it would seem like we earned it on this game
savedMoneyScore = scorer.getCurrentScore();
// After it's been loaded, delete the save file
deleteSave();
return true;
} catch (IOException ignored) {
}
}
return false;
}
代码示例来源:origin: SquidPony/SquidLib
this.ignoreInput = ignoreInput;
FileHandle prefFile;
if(Gdx.files.isLocalStorageAvailable() && (prefFile = Gdx.files.local("keymap.preferences")).exists())
代码示例来源:origin: moribitotech/MTX
file = Gdx.files.local(strFile);
} catch (Exception e) {
MtxLogger.log(logActive, true, logTag,
内容来源于网络,如有侵权,请联系作者删除!