当前位置: 首页>>代码示例>>Java>>正文


Java FileHandle.exists方法代码示例

本文整理汇总了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;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:20,代码来源:AndroidModLoader.java

示例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;
    }
}
 
开发者ID:gradualgames,项目名称:ggvm,代码行数:19,代码来源:PCMenu.java

示例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;
}
 
开发者ID:mcgeer,项目名称:Climatar,代码行数:17,代码来源:TitleController.java

示例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;
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:17,代码来源:Save.java

示例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;
}
 
开发者ID:whitecostume,项目名称:libgdx_ui_editor,代码行数:22,代码来源:Config.java

示例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;
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:26,代码来源:SaveAreaIO.java

示例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);
}
 
开发者ID:Benjozork,项目名称:Onyx,代码行数:29,代码来源:Configs.java

示例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);
    }
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:24,代码来源:Credits.java

示例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;
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:19,代码来源:Save.java

示例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)));
    }
}
 
开发者ID:MartensCedric,项目名称:Hexpert,代码行数:27,代码来源:LevelSelectScreen.java

示例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;
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:17,代码来源:GameScreen.java

示例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;
}
 
开发者ID:mcgeer,项目名称:Climatar,代码行数:17,代码来源:TitleController.java

示例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);
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:23,代码来源:Level.java

示例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();
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:15,代码来源:FileUtils.java

示例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;
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:17,代码来源:FileUtils.java


注:本文中的com.badlogic.gdx.files.FileHandle.exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。