Java 类com.badlogic.gdx.files.FileHandle 实例源码

项目:cocos2d-java    文件:FileUtils.java   
/**
 * 从搜索队列中找到完整文件路径
 * @param fileName
 * @return
 */
public FullFilePath fullPathForFileName(String fileName) {
    FullFilePath ret = _fullPathCache.get(fileName);
    if(ret != null) {
        return ret;
    }

    for(int i = 0; i < _searchPathArray.size; ++i) {
        FullFilePath curr = _searchPathArray.get(i);
        System.out.println(curr);
        FileHandle fh = Gdx.files.getFileHandle(curr.path + fileName, curr.type);
        if(fh != null && fh.exists()) {
            ret = curr;
            break;
        }
    }

    if(ret == null) {
        ret = _defaultResRootPath;
    }

    _fullPathCache.put(fileName, ret);
    return ret;
}
项目:Cubes_2    文件:ClientSaveManager.java   
public static Save createSave(String name, String generatorID, Gamemode gamemode, String seedString) {
  if (name != null) name = name.trim();
  if (name == null || name.isEmpty()) name = "world-" + Integer.toHexString(MathUtils.random.nextInt());
  FileHandle folder = getSavesFolder();
  FileHandle handle = folder.child(name);
  handle.mkdirs();
  Compatibility.get().nomedia(handle);
  Save s = new Save(name, handle);

  SaveOptions options = new SaveOptions();
  options.setWorldSeed(seedString);
  options.worldType = generatorID;
  options.worldGamemode = gamemode;
  s.setSaveOptions(options);

  return s;
}
项目:Cubes    文件:SaveAreaIO.java   
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;
  }
}
项目:Cubes    文件:AndroidModLoader.java   
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;
}
项目:libgdx_ui_editor    文件:Config.java   
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;
}
项目:enklave    文件:BitmapFontWriter.java   
/** A utility method to write the given array of pixmaps to the given output directory, with the specified file name. If the
 * pages array is of length 1, then the resulting file ref will look like: "fileName.png".
 *
 * If the pages array is greater than length 1, the resulting file refs will be appended with "_N", such as "fileName_0.png",
 * "fileName_1.png", "fileName_2.png" etc.
 *
 * The returned string array can then be passed to the <tt>writeFont</tt> method.
 *
 * Note: None of the pixmaps will be disposed.
 *
 * @param pages the pages of pixmap data to write
 * @param outputDir the output directory
 * @param fileName the file names for the output images
 * @return the array of string references to be used with <tt>writeFont</tt> */
public static String[] writePixmaps (Pixmap[] pages, FileHandle outputDir, String fileName) {
    if (pages==null || pages.length==0)
        throw new IllegalArgumentException("no pixmaps supplied to BitmapFontWriter.write");

    String[] pageRefs = new String[pages.length];

    for (int i=0; i<pages.length; i++) {
        String ref = pages.length==1 ? (fileName+".png") : (fileName+"_"+i+".png");

        //the ref for this image
        pageRefs[i] = ref;

        //write the PNG in that directory
        PixmapIO.writePNG(outputDir.child(ref), pages[i]);
    }
    return pageRefs;
}
项目:Cubes    文件:ClientSaveManager.java   
public static Save createSave(String name, String generatorID, Gamemode gamemode, String seedString) {
  if (name != null) name = name.trim();
  if (name == null || name.isEmpty()) name = "world-" + Integer.toHexString(MathUtils.random.nextInt());
  FileHandle folder = getSavesFolder();
  FileHandle handle = folder.child(name);
  handle.mkdirs();
  Compatibility.get().nomedia(handle);
  Save s = new Save(name, handle);

  SaveOptions options = new SaveOptions();
  options.setWorldSeed(seedString);
  options.worldType = generatorID;
  options.worldGamemode = gamemode;
  s.setSaveOptions(options);

  return s;
}
项目:Cubes_2    文件:Performance.java   
public static void toggleTracking() {
    synchronized (enabled) {
        if (enabled.get()) {
            stopTracking();
            FileHandle dir = Compatibility.get().getBaseFolder().child("performance");
            Compatibility.get().nomedia(dir);
            dir.mkdirs();
            try {
                save(dir.child(System.currentTimeMillis() + ".cbpf").file());
            } catch (IOException e) {
                Debug.crash(e);
            }
        } else {
            clear();
            startTracking();
        }
    }
}
项目:school-game    文件:Level.java   
/**
 * 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);
}
项目:Cubes_2    文件:JsonLoader.java   
private static Multimap<JsonStage, JsonValue> load(Map<String, FileHandle> map) throws IOException {
 try {
  Multimap<JsonStage, JsonValue> m = new Multimap<JsonStage, JsonValue>();
  for (Map.Entry<String, FileHandle> entry : map.entrySet()) {
    JsonStage stage = null;
    if (entry.getKey().startsWith("block")) {
      stage = JsonStage.BLOCK;
    } else if (entry.getKey().startsWith("item")) {
      stage = JsonStage.ITEM;
    } else if (entry.getKey().startsWith("recipe")) {
      stage = JsonStage.RECIPE;
    } else {
      throw new CubesException("Invalid json file path \"" + entry.getKey() + "\"");
    }

    Reader reader = entry.getValue().reader();

      m.put(stage, Json.parse(reader));
    } 
  }finally {
      reader.close();
    }
  return m;
}
项目:Cubes_2    文件:Settings.java   
public static boolean read() {
    FileHandle fileHandle = Compatibility.get().getBaseFolder().child("settings.json");

    try {
        Reader reader = fileHandle.reader();
        JsonObject json = Json.parse(reader).asObject();
        reader.close();

        for (Member member : json) {
            Setting setting = set.settings.get(member.getName());
            setting.readJson(member.getValue());
        }

        return true;
    } catch (Exception e) {
        Log.error("Failed to read settings", e);
        fileHandle.delete();
        return false;
    }
}
项目:Cubes_2    文件:AndroidModLoader.java   
public static String hashFile(FileHandle fileHandle) throws Exception {
  InputStream inputStream = fileHandle.read();
  try {
    MessageDigest digest = MessageDigest.getInstance("SHA-256");

    byte[] bytesBuffer = new byte[1024];
    int bytesRead;
int n =inputStream.read(bytesBuffer);
    while ((bytesRead = n) != -1) {
      digest.update(bytesBuffer, 0, bytesRead);
      n=inputStream.read(bytesBuffer);
    }

    byte[] hashedBytes = digest.digest();
    return convertByteArrayToHexString(hashedBytes);
  } catch (IOException ex) {
    throw new CubesException("Could not generate hash from file " + fileHandle.path(), ex);
  } finally {
    StreamUtils.closeQuietly(inputStream);
  }
}
项目:Cubes_2    文件:Save.java   
public Save(String name, FileHandle fileHandle, boolean readOnly) {
    this.name = name;
    this.fileHandle = fileHandle;
    this.readOnly = readOnly;

    if (!this.readOnly) {
        this.fileHandle.mkdirs();
        Compatibility.get().nomedia(this.fileHandle);

        folderArea().mkdirs();
        Compatibility.get().nomedia(folderArea());

        folderPlayer().mkdirs();
        Compatibility.get().nomedia(folderPlayer());

        folderCave().mkdirs();
        Compatibility.get().nomedia(folderCave());
    }
}
项目:Cubes    文件:Graphics.java   
public static void takeScreenshot() {
  Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
  FileHandle dir = Compatibility.get().getBaseFolder().child("screenshots");
  dir.mkdirs();
  FileHandle f = dir.child(System.currentTimeMillis() + ".png");
  try {
    PixmapIO.PNG writer = new PixmapIO.PNG((int) (pixmap.getWidth() * pixmap.getHeight() * 1.5f));
    try {
      writer.setFlipY(true);
      writer.write(f, pixmap);
    } finally {
      writer.dispose();
    }
  } catch (IOException ex) {
    throw new CubesException("Error writing PNG: " + f, ex);
  } finally {
    pixmap.dispose();
  }
  Log.info("Took screenshot '" + f.file().getAbsolutePath() + "'");
}
项目:Cubes_2    文件:ModInputStream.java   
@Override
public ModFile getNextModFile() throws IOException {
    FileHandle file = files.pollFirst();
    if (file != null)
        return new FolderModFile(file);
    FileHandle folder = folders.pollFirst();
    if (folder == null)
        return null;
    for (FileHandle f : folder.list()) {
        if (f.isDirectory()) {
            folders.add(f);
        } else {
            files.add(f);
        }
    }
    return new FolderModFile(folder);
}
项目:Cubes_2    文件:Save.java   
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;
    }
}
项目:Climatar    文件:TitleController.java   
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;
}
项目:cocos2d-java    文件:FileUtils.java   
/**
 * 获取文件实例
 * @param fileName
 * @return
 */
public FileHandle getFileHandle(final String fileName) {
    FullFilePath ffp = fullPathForFileName(fileName);
    if(ffp == null) {
        CCLog.engine(TAG, "file not found : " + fileName);
        return null;
    }

    FileHandle fh = Gdx.files.getFileHandle(ffp.path + fileName, ffp.type);

    return fh;
}
项目:Cubes    文件:LogMenu.java   
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);
}
项目:cocos2d-java    文件:FileUtils.java   
/**
*  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;
}
项目:guitar-finger-trainer    文件:SettingsUtil.java   
public static void load () {
    try {
        FileHandle filehandle = Gdx.files.local(file);

        String[] strings = filehandle.readString().split("\n");

        backForwardEnabled = Boolean.parseBoolean(strings[0]);
        autoMoveToNext = Boolean.parseBoolean(strings[1]);
        bpm = Integer.parseInt(strings[2]);
    } catch (Throwable e) {
        // :( It's ok we have defaults
    }
}
项目:cocos2d-java    文件:TextureCache.java   
/** 
 * 想缓存中添加纹理 以path为键值
*/
public Texture addImage(String path) {
    Texture t = _textures.get(path);

    if(t == null) {
        FileHandle handle = FileUtils.getInstance().getFileHandle(path);
        t = new Texture(handle);
        _textures.put(path, t);
    }

    return t;
}
项目:Cubes    文件:SaveAreaIO.java   
public static boolean write(Save save, Area area) {
  if (save.readOnly) return false;
  if (!area.isReady()) return false;

  AreaMap map = area.areaMap();
  DataGroup[] dataGroups;
  if (map == null || map.world == null || map.world.entities == null) {
    dataGroups = new DataGroup[0];
  } else {
    dataGroups = map.world.entities.getEntitiesForSave(area.areaX, area.areaZ);
  }
  if (!area.modifiedSinceSave(dataGroups)) return false;
  area.saveModCount();

  Deflater deflater = deflaterThreadLocal.get();

  FileHandle file = file(save, area.areaX, area.areaZ);
  try {
    deflater.reset();
    OutputStream stream = file.write(false, 8192);
    DeflaterOutputStream deflaterStream = new DeflaterOutputStream(stream, deflater);
    BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(deflaterStream);
    DataOutputStream dataOutputStream = new DataOutputStream(bufferedOutputStream);
    area.writeSave(dataOutputStream, dataGroups);
    bufferedOutputStream.flush();
    deflaterStream.finish();
    stream.close();
  } catch (Exception e) {
    Log.error("Failed to write area " + area.areaX + "," + area.areaZ, e);
    return false;
  }

  return true;
}
项目:cocos2d-java    文件:TMXTiledMap.java   
/** initializes a TMX Tiled Map with a TMX file */
public boolean initWithTMXFile(String tmxFile) {
 if(_tileMap != null) {
  _tileMap.dispose();
 }
 TmxMapLoader newLoader = new TmxMapLoader() {
  public FileHandle resolve(String fileName) {
   return CC.File(fileName);
  }
 };
 _tileMap = newLoader.load(tmxFile);
 _initProperties();
 _tileMapRender = new OrthogonalTiledMapRenderer(_tileMap, 1f);
 return true;
}
项目:Cubes    文件:SaveAreaIO.java   
public static FileHandle file(Save save, int x, int z) {
  FileHandle folderArea = save.folderArea();
  FileHandle xMostSignificant = folderArea.child(Integer.toString(x & 0xFFFF0000));
  FileHandle xLeastSignificant = xMostSignificant.child(Integer.toString(x & 0xFFFF));
  FileHandle zMostSignificant = xLeastSignificant.child(Integer.toString(z & 0xFFFF0000));
  zMostSignificant.mkdirs();
  Compatibility.get().nomedia(zMostSignificant);

  return zMostSignificant.child(Integer.toString(z & 0xFFFF));
}
项目:ggvm    文件:GGVmApplication.java   
/**
 * Saves GGVm's current state to a save state file. This is used
 * when the user quits GGVm so they can resume their game where they
 * left off.
 * TODO: Implement for mobile devices.
 */
private void saveState() {
    Gdx.app.log(getClass().getSimpleName(), "saveState()");
    try {
        FileHandle file = Gdx.files.local("state.sav");
        OutputStream outputStream = file.write(false);
        ggvm.saveState(outputStream);
        soundtrackManager.save(outputStream);
    } catch (IOException ex) {
        Gdx.app.error(getClass().getSimpleName(), "Error saving game state.", ex);
    }
}
项目:Cubes_2    文件:LogMenu.java   
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);
}
项目:Cubes_2    文件:AOTextureGenerator.java   
protected static void generate(FileHandle file, float strength) {
    Pixmap blocks = new Pixmap(INDIVIDUAL_SIZE * 3, INDIVIDUAL_SIZE * 3, AOTextureGenerator.FORMAT);
    Pixmap gaussian = new Pixmap(INDIVIDUAL_SIZE, INDIVIDUAL_SIZE, AOTextureGenerator.FORMAT);

    Pixmap output = new Pixmap(TEXTURE_SIZE, TEXTURE_SIZE, AOTextureGenerator.FORMAT);

    double[][] gwm = AOTextureGenerator.gaussianWeightMatrix(SIGMA);
    int gaussianRadius = (gwm.length - 1) / 2;

    Color blockColor = new Color(strength, strength, strength, 1f);

    for (int i = 0; i < TOTAL; i++) {
        String n = name(i);
        System.out.print(n + " ");

        AOTextureGenerator.clearPixmap(blocks);
        AOTextureGenerator.clearPixmap(gaussian);

        AOTextureGenerator.setupPixmap(blocks, i, blockColor);

        AOTextureGenerator.gaussianPixmap(blocks, gaussian, gwm, gaussianRadius);

        // PixmapIO.writePNG(folder.child(n + "_blocks_" + sigma + ".png"),
        // blocks);
        // PixmapIO.writePNG(folder.child(n + "_gaussian_" + sigma +
        // ".png"), gaussian);

        output.drawPixmap(gaussian, (i % SQRT_TOTAL) * INDIVIDUAL_SIZE, (i / SQRT_TOTAL) * INDIVIDUAL_SIZE, 0, 0,
                INDIVIDUAL_SIZE, INDIVIDUAL_SIZE);

        if (i % SQRT_TOTAL == SQRT_TOTAL - 1)
            System.out.println();
    }

    PixmapIO.writePNG(file, output);
    output.dispose();
    blocks.dispose();
    gaussian.dispose();
}
项目:Klooni1010    文件:GameScreen.java   
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();
    }
}
项目:Cubes_2    文件:BitmapFontWriter.java   
/** A convenience method to write pixmaps by page; typically returned from a PixmapPacker when used alongside
 * FreeTypeFontGenerator.
 *
 * @param pages the pages containing the Pixmaps
 * @param outputDir the output directory
 * @param fileName the file name
 * @return the file refs */
public static String[] writePixmaps (Array<Page> pages, FileHandle outputDir, String fileName) {
  Pixmap[] pix = new Pixmap[pages.size];
  for (int i = 0; i < pages.size; i++) {
    pix[i] = pages.get(i).getPixmap();
  }
  return writePixmaps(pix, outputDir, fileName);
}
项目:bobbybird    文件:LoadingState.java   
private void packPixmaps() {
    for (String directory : getCore().getImagePacks().keys()) {
        for (String name : getCore().getImagePacks().get(directory)) {
            FileHandle file = Gdx.files.local(directory + "/" + name + ".png");
            getCore().getPixmapPacker().pack(file.nameWithoutExtension(), getCore().getAssetManager().get(file.path(), Pixmap.class));
        }
    }

    getCore().getPixmapPacker().pack("white", getCore().getAssetManager().get(Core.DATA_PATH + "/gfx/white.png", Pixmap.class));

    TextureAtlas atlas = getCore().getPixmapPacker().generateTextureAtlas(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear, false);
    getCore().setAtlas(atlas);
}
项目:Mindustry    文件:FileChooser.java   
void print(){

            System.out.println("\n\n\n\n\n\n");
            int i = 0;
            for(FileHandle file : history){
                i ++;
                if(index == i){
                    System.out.println("[[" + file.toString() + "]]");
                }else{
                    System.out.println("--" + file.toString() + "--");
                }
            }
        }
项目:gdx-fireapp    文件:Storage.java   
/**
 * {@inheritDoc}
 */
@Override
public void upload(FileHandle file, String path, UploadCallback callback)
{
    StorageReference dataRef = firebaseStorage().getReference().child(path);
    UploadTask uploadTask = dataRef.putFile(Uri.fromFile(file.file()));
    processUpload(uploadTask, callback);
}
项目:Mindustry    文件:BundleGen.java   
public static void cleanBundles(FileHandle file){
    String[] strings = file.readString().split("\n");
    FileHandle out = Gdx.files.absolute("/home/anuke/out.properties");
    out.writeString("", false);
    for(String string : strings){
        if(!string.contains(".description")){
            out.writeString(string + "\n", true);
        }
    }
}
项目:Cubes_2    文件:JsonLoader.java   
public static void loadCore() {
  AssetManager core = Assets.getCoreAssetManager();
  HashMap<String, FileHandle> map = new HashMap<String, FileHandle>();
  for (Asset j : core.getAssets("json/")) {
    map.put(j.getPath().substring(5), j.getFileHandle());
  }
  try {
    coreMap = load(map);
  } catch (IOException e) {
    throw new CubesException("Failed to load core json", e);
  }
}
项目:school-game    文件:Credits.java   
/**
 * 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));
    }
}
项目:libgdx_ui_editor    文件:StageLoad.java   
public static void loadScene(Group parentGroup,String path){
    if (path==null || parentGroup == null) return;
    FileHandle sceneFile = Gdx.files.internal(path);
    if (sceneFile.exists()){
        try {
            XmlUtils.readFile(parentGroup,sceneFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
项目:Cubes_2    文件:ModManager.java   
private static List<FileHandle> getModFiles() {
    FileHandle base = Compatibility.get().getBaseFolder().child("mods");
    base.mkdirs();
    Compatibility.get().nomedia(base);
    ArrayList<FileHandle> fileHandles = new ArrayList<FileHandle>();
    fileHandles.addAll(modManager.extraMods);
    Collections.addAll(fileHandles, base.list(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            String s = pathname.getName().toLowerCase();
            return s.endsWith(".cm");
        }
    }));
    return fileHandles;
}
项目:libgdx-crypt-texture    文件:TextureEncryptor.java   
public static void encryptToFile(Crypto crypto, File inputFile, File outputFile) {
    FileHandle inputFileHandle = new FileHandle(inputFile);
    byte[] bytes = inputFileHandle.readBytes();
    crypto.decrypt(bytes, true);

    FileHandle outputFileHandle = new FileHandle(outputFile);
    outputFileHandle.writeBytes(bytes, false);
}
项目:libgdx-crypt-texture    文件:TextureDecryptor.java   
public static Texture loadTexture(Crypto crypto, FileHandle file, Pixmap.Format format, boolean useMipMaps) {
    try {
        byte[] bytes = file.readBytes();
        if (crypto != null) {
            bytes = crypto.decrypt(bytes, true);
        }
        Pixmap pixmap = new Pixmap(new Gdx2DPixmap(bytes, 0, bytes.length, 0));
        return new Texture(pixmap, format, useMipMaps);
    } catch (Exception e) {
        throw new GdxRuntimeException("Couldn't load file: " + file, e);
    }
}