本文整理匯總了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);
}