當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。