本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}