本文整理汇总了Java中com.badlogic.gdx.files.FileHandle.exists方法的典型用法代码示例。如果您正苦于以下问题:Java FileHandle.exists方法的具体用法?Java FileHandle.exists怎么用?Java FileHandle.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.files.FileHandle
的用法示例。
在下文中一共展示了FileHandle.exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToDex
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
private FileHandle convertToDex(FileHandle fileHandle) throws Exception {
String inputHash = hashFile(fileHandle);
FileHandle cacheDir = new FileHandle(androidCompatibility.androidLauncher.getCacheDir());
FileHandle dexDir = cacheDir.child("converted_mod_dex");
dexDir.mkdirs();
FileHandle dexFile = dexDir.child(inputHash + ".dex");
if (!dexFile.exists()) {
Log.warning("Trying to convert jar to dex: " + fileHandle.file().getAbsolutePath());
com.android.dx.command.dexer.Main.Arguments arguments = new com.android.dx.command.dexer.Main.Arguments();
arguments.parse(new String[]{"--output=" + dexFile.file().getAbsolutePath(), fileHandle.file().getAbsolutePath()});
int result = com.android.dx.command.dexer.Main.run(arguments);
if (result != 0) throw new CubesException("Failed to convert jar to dex [" + result + "]: " + fileHandle.file().getAbsolutePath());
Log.warning("Converted jar to dex: " + fileHandle.file().getAbsolutePath());
}
return dexFile;
}
示例2: action
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
@Override
public void action() {
if (!visited) {
text = "YOU WILL LOSE PROGRESS. OK?";
visited = true;
} else {
resetVisited();
soundtrackManager.stopSound();
inputProcessor.activate();
inputProcessor.saveConfiguration();
FileHandle file = Gdx.files.local("state.sav");
if (file.exists()) {
file.delete();
}
ggvm.reset();
menu = topLevelMenu;
}
}
示例3: 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;
}
示例4: readCave
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public Cave readCave(AreaReference areaReference) {
if (fileHandle == null) return null;
FileHandle folder = folderCave();
FileHandle file = folder.child(areaReference.areaX + "_" + areaReference.areaZ);
if (!file.exists()) return null;
try {
InputStream read = file.read();
DataInputStream dataInputStream = new DataInputStream(read);
Cave cave = Cave.read(dataInputStream);
read.close();
return cave;
} catch (IOException e) {
Log.warning("Failed to read cave", e);
return null;
}
}
示例5: getImageFilePath
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public static FileHandle getImageFilePath(String path){
StringBuilder stringBuilder = new StringBuilder();
String projectPath = getProjectPath();
stringBuilder.append(projectPath);
if (!projectPath.isEmpty()){
if (!projectPath.endsWith("/")){
stringBuilder.append("/");
}
stringBuilder.append(path==null?"":path);
String imagePath = stringBuilder.toString();
FileHandle fileHandle = new FileHandle(imagePath);
if (fileHandle.exists() && fileHandle.file().isFile()){
return fileHandle;
} else{
return Gdx.files.internal("badlogic.jpg");
}
}
return null;
}
示例6: read
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public static Area read(Save save, int x, int z) {
FileHandle file = file(save, x, z);
if (!file.exists()) {
//Log.warning("Area does not exist");
return null;
}
Inflater inflater = inflaterThreadLocal.get();
try {
inflater.reset();
InputStream inputStream = file.read(8192);
InflaterInputStream inflaterInputStream = new InflaterInputStream(inputStream, inflater);
BufferedInputStream bufferedInputStream = new BufferedInputStream(inflaterInputStream);
DataInputStream dataInputStream = new DataInputStream(bufferedInputStream);
Area area = new Area(x, z);
area.read(dataInputStream);
dataInputStream.close();
return area;
} catch (Exception e) {
Log.error("Failed to read area " + x + "," + z, e);
return null;
}
}
示例7: load
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
/**
* Loads a certain config file
*
* @param internalPath the path for the file to be loaded from
* @param clazz the class of the config file that has to be loaded
* @return the loaded file
*/
public static <T> Maybe<T> load(String internalPath, Class<T> clazz) {
if (cache.containsKey(internalPath)) {
return Maybe.of((T) cache.get(internalPath));
}
FileHandle handle = files.internal(internalPath);
if (! handle.exists())
return Maybe.empty();
T config = json.fromJson(clazz, handle);
if (config == null) {
log.print("Could not read config file '%s'", internalPath);
return Maybe.empty();
}
cache.put(internalPath, config);
log.print("Config '%s' loaded and cached.", internalPath);
return Maybe.of(config);
}
示例8: create
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
/**
* Initialisierung.
*
* @param game zeigt auf das SchoolGame, dass das Spiel verwaltet
*/
@Override
public void create(SchoolGame game) {
this.game = game;
batch = new SpriteBatch();
font = game.getDefaultFont();
fontLayout = new GlyphLayout();
offset -= Gdx.graphics.getHeight() / 2 - 35;
FileHandle credits = Gdx.files.internal("data/misc/credits.txt");
if (credits.exists() && !credits.isDirectory())
{
prepareCredits(credits);
}
}
示例9: readCave
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public Cave readCave(AreaReference areaReference) {
if (fileHandle == null)
return null;
FileHandle folder = folderCave();
FileHandle file = folder.child(areaReference.areaX + "_" + areaReference.areaZ);
if (!file.exists())
return null;
try {
InputStream read = file.read();
DataInputStream dataInputStream = new DataInputStream(read);
Cave cave = Cave.read(dataInputStream);
read.close();
return cave;
} catch (IOException e) {
Log.warning("Failed to read cave", e);
return null;
}
}
示例10: getObjectivePassed
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
private boolean[] getObjectivePassed(int level)
{
FileHandle mapresFile = Gdx.files.local(hexpert.levelIndex.get(level) + ".mapres");
if(mapresFile.exists())
{
MapResult mapResult = new JSONDeserializer<MapResult>().deserialize(mapresFile.readString());
//I would like to verify the integrity of every level with this code, but it does not quite
//work yet
//String mapLoc = Gdx.files.internal("maps/" + hexpert.levelIndex.get(level) + ".hexmap").readString();
//Map map = new JSONDeserializer<Map>().deserialize(mapLoc);
//map.setBuildingTypes(mapResult.getBuildings());
//HexMap<TileData> grid = map.build();
//mapResult.updateObjectives(map.getObjectives(), grid);
//JSONSerializer jsonSerializer = new JSONSerializer();
//Gdx.files.local(hexpert.levelIndex.get(level) + ".mapres").writeString(jsonSerializer.deepSerialize(mapResult), false);
return mapResult.getObjectivePassed();
}else{
throw new MapLoadException(String.format("Can't find %s.mapres", hexpert.levelIndex.get(level)));
}
}
示例11: tryLoad
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
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;
}
示例12: 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;
}
示例13: loadMap
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
/**
* Lädt die Map aus der Datei in den Speicher.
*
* Wird von {@link #initMap()} aufgerufen.
*/
private void loadMap()
{
FileHandle mapFile = Gdx.files.internal("data/maps/" + mapName + ".tmx");
if (!mapFile.exists() || mapFile.isDirectory())
{
Gdx.app.error("ERROR", "The map file " + mapName + ".tmx doesn't exists!");
levelManager.exitToMenu();
return;
}
TmxMapLoader.Parameters mapLoaderParameters = new TmxMapLoader.Parameters();
mapLoaderParameters.textureMagFilter = Texture.TextureFilter.Nearest;
mapLoaderParameters.textureMinFilter = Texture.TextureFilter.Nearest;
tileMap = new TmxMapLoader().load(mapFile.path(), mapLoaderParameters);
}
示例14: isFileExist
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
/**
* Checks whether a file exists.
*
* @note If a relative path was passed in, it will be inserted a default root path at the beginning.
* @param filename The path of the file, it could be a relative or absolute path.
* @return True if the file exists, false if not.
*/
public boolean isFileExist( String filename) {
FileHandle fh = getFileHandle(filename);
if(fh == null) {
return false;
}
return fh.exists();
}
示例15: getFileSize
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
/**
* Retrieve the file size.
*
* @note If a relative path was passed in, it will be inserted a default root path at the beginning.
* @param filepath The path of the file, it could be a relative or absolute path.
* @return The file size.
*/
public long getFileSize( String filepath) {
FileHandle fh = getFileHandle(filepath);
if(fh != null) {
if(fh.exists()) {
return fh.length();
}
}
return 0;
}