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


Java FileHandle.write方法代码示例

本文整理汇总了Java中com.badlogic.gdx.files.FileHandle.write方法的典型用法代码示例。如果您正苦于以下问题:Java FileHandle.write方法的具体用法?Java FileHandle.write怎么用?Java FileHandle.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.files.FileHandle的用法示例。


在下文中一共展示了FileHandle.write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveState

import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:gradualgames,项目名称:ggvm,代码行数:18,代码来源:GGVmApplication.java

示例2: write

import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
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;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:38,代码来源:SaveAreaIO.java

示例3: writeCave

import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public void writeCave(AreaReference areaReference, Cave cave) {
	if (readOnly)
		return;

	FileHandle folder = folderCave();
	FileHandle file = folder.child(areaReference.areaX + "_" + areaReference.areaZ);
	try {
		OutputStream write = file.write(false);
		DataOutputStream dataOutputStream = new DataOutputStream(write);
		cave.write(dataOutputStream);
		write.close();
	} catch (IOException e) {
		Log.warning("Failed to write cave", e);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:16,代码来源:Save.java

示例4: write

import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
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;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:35,代码来源:SaveAreaIO.java

示例5: writeCave

import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public void writeCave(AreaReference areaReference, Cave cave) {
  if (readOnly) return;

  FileHandle folder = folderCave();
  FileHandle file = folder.child(areaReference.areaX + "_" + areaReference.areaZ);
  try {
    OutputStream write = file.write(false);
    DataOutputStream dataOutputStream = new DataOutputStream(write);
    cave.write(dataOutputStream);
    write.close();
  } catch (IOException e) {
    Log.warning("Failed to write cave", e);
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:15,代码来源:Save.java

示例6: openFileOutput

import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public OutputStream openFileOutput(String fileName) {
	final FileHandle fh = Gdx.files.external(basePath != null ? basePath + fileName : fileName);
	return fh.write(false);
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:5,代码来源:Game.java


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