use of java.io.FileOutputStream in project playn by threerings.
the class AndroidSurfaceGL method onSurfaceLost.
@Override
public void onSurfaceLost() {
try {
AndroidGLContext actx = (AndroidGLContext) ctx;
bindFramebuffer();
ByteBuffer pixelBuffer = ByteBuffer.allocate(texWidth * texHeight * 4);
actx.gl.glReadPixels(0, 0, texWidth, texHeight, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixelBuffer);
actx.checkGLError("glReadPixels");
try {
cachedPixels = new File(cacheDir, "surface-" + Integer.toHexString(hashCode()));
FileOutputStream out = new FileOutputStream(cachedPixels);
out.write(pixelBuffer.array());
out.close();
} catch (IOException e) {
PlayN.reportError("IOException writing cached Surface to file.", e);
cachedPixels = null;
}
pixelBuffer = null;
} catch (OutOfMemoryError e) {
PlayN.reportError("OutOfMemoryError reading cached Surface to buffer.", e);
cachedPixels = null;
}
clearTexture();
}
use of java.io.FileOutputStream in project Android-ImageResizer by svenkapudija.
the class ImageWriter method writeToFile.
public static boolean writeToFile(Bitmap image, File file) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
image.compress(CompressFormat.JPEG, 100, bytes);
try {
FileOutputStream fos = new FileOutputStream(file);
fos.write(bytes.toByteArray());
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
use of java.io.FileOutputStream in project syncany by syncany.
the class TestFileUtil method createFile.
private static void createFile(File fileToCreate, long sizeInBytes, Random randomGen) throws IOException {
if (fileToCreate != null && fileToCreate.exists()) {
throw new IOException("File already exists");
}
FileOutputStream fos = new FileOutputStream(fileToCreate);
int bufSize = 4096;
long cycles = sizeInBytes / (long) bufSize;
for (int i = 0; i < cycles; i++) {
byte[] randomByteArray = createArray(bufSize, randomGen);
fos.write(randomByteArray);
}
// create last one
// modulo cannot exceed integer range, so cast should be ok
byte[] arr = createArray((int) (sizeInBytes % bufSize), randomGen);
fos.write(arr);
fos.close();
}
use of java.io.FileOutputStream in project syncany by syncany.
the class TestFileUtil method writeByteArrayToFile.
public static void writeByteArrayToFile(byte[] inputByteArray, File fileToCreate) throws IOException {
FileOutputStream fos = new FileOutputStream(fileToCreate);
fos.write(inputByteArray);
fos.close();
}
use of java.io.FileOutputStream in project fino by sysdream.
the class InspectionStub method loadMacro.
/**
* @see IInspectionService.loadMacro
*/
public int loadMacro(final String name, final String dex) throws RemoteException {
/*
* Then try and load the class
*/
try {
String tmpname = UUID.randomUUID().toString() + ".jar";
final File internal = new File(this.context.getDir("dex", Context.MODE_PRIVATE), tmpname);
final File optimized = this.context.getDir("outdex", Context.MODE_PRIVATE);
final FileOutputStream fos = new FileOutputStream(internal);
fos.write(Base64.decode(dex, Base64.DEFAULT));
fos.close();
DexClassLoader loader = new DexClassLoader(internal.getAbsolutePath(), optimized.getAbsolutePath(), null, this.context.getClassLoader());
Class clazz = loader.loadClass(name);
return pushObject(clazz);
} catch (Exception e) {
//TODO debug
e.printStackTrace();
return -1;
}
}
Aggregations