Code example for FileChannel

Methods: mapclose

0
	 
	private Buffer createMappedBuffer(int size) throws IOException {
		tempFile = File.createTempFile(".bmp", null);
		tempRandomAccessFile = new RandomAccessFile(tempFile, "rw");
		channel = tempRandomAccessFile.getChannel();
		return channel.map(MapMode.READ_WRITE, 0, size);
	} 
	 
	private Bitmap clearBitmap(Bitmap bmp) {
		int width = bmp.getWidth();
		int height = bmp.getHeight();
		Config config = bmp.getConfig();
		bmp.recycle();
		return Bitmap.createBitmap(width, height, config);
	} 
 
	private void cleanUp() throws IOException { 
		channel.close();
		tempRandomAccessFile.close();
		tempFile.delete();
	} 
	 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE