本文整理匯總了Java中com.badlogic.gdx.files.FileHandle.writeBytes方法的典型用法代碼示例。如果您正苦於以下問題:Java FileHandle.writeBytes方法的具體用法?Java FileHandle.writeBytes怎麽用?Java FileHandle.writeBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.files.FileHandle
的用法示例。
在下文中一共展示了FileHandle.writeBytes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRealFileHandle
import com.badlogic.gdx.files.FileHandle; //導入方法依賴的package包/類
public static FileHandle getRealFileHandle(String zipEntryPath, ZipFile zipFile) {
if (Gdx.files.local(zipEntryPath).exists()) {
return Gdx.files.local(zipEntryPath);
} else {
Gdx.app.log("OBB", "Unzipping file '" + zipEntryPath + "'...");
try {
FileHandle unzippedFile;
ZipEntry entry = zipFile.getEntry(zipEntryPath);
if (entry != null) {
unzippedFile = Gdx.files.local(zipEntryPath);
InputStream is = zipFile.getInputStream(entry);
byte[] buffer = new byte[65536];
int readLength;
while ((readLength = is.read(buffer)) >= 0) {
unzippedFile.writeBytes(buffer, 0, readLength, true);
}
return unzippedFile;
} else {
Gdx.app.error("OBB", "Entry '" + zipEntryPath + "' not found inside zip file.");
}
} catch (IOException ioe) {
Gdx.app.error("OBB", "A problem occurred while writing to the local file.");
}
}
return null;
}
示例2: encryptToFile
import com.badlogic.gdx.files.FileHandle; //導入方法依賴的package包/類
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);
}