gt:     		catch (IOException e) {};
context: package com.example.g2template;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  
  import javax.microedition.khronos.egl.EGL10;
  import javax.microedition.khronos.egl.EGLConfig;
  import javax.microedition.khronos.egl.EGLContext;
  import javax.microedition.khronos.egl.EGLDisplay;
  import javax.microedition.khronos.opengles.GL10;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.res.AssetManager;
  import android.graphics.Bitmap;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Paint;
  import android.graphics.PixelFormat;
  import android.graphics.Rect;
  import android.opengl.GLSurfaceView;
  import android.os.Bundle;
  import android.view.MotionEvent;
  
  public class g2template extends Activity
  {
  	public int AM_CONNECT = 0;
  	public int AM_INIT = 1;
  	public int AM_QUIT = 2;
  	public int AM_RESIZE = 3;
  	public int AM_DRAW = 4;
  	public int AM_TOUCH_DOWN = 5;
  	public int AM_TOUCH_UP = 6;
  	public int AM_TOUCH_MOVE = 7;
  	public G2MPView GLView;
  	public AssetManager AssetMgr;
  	public FileManager FileMgr;
  	private InputStream AssetStream = null;
  	private Bitmap FontBitmap;
  	private int FontWidth;
  	private int FontHeight;
  	private boolean CanDraw;
  	private boolean Closing;
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          CanDraw = false;
          Closing = false;
          AssetMgr = getAssets();
          FileMgr = new FileManager();
          GLView = new G2MPView(getApplication().getApplicationContext());
      	setContentView(GLView);
      	GLView.setKeepScreenOn(true);
      	setTitle("G2MP");
      }
      @Override
      public void onDestroy () {
      	Closing = true;
      	while (CanDraw) ;
      	super.onDestroy();
      }
      @Override
      public void onStop () {
      	if (!Closing) {Closing = true; while (CanDraw); finish();}
      	else while (CanDraw);
      	super.onStop();
      }
      @Override
      public void onPause () {
      	if (!Closing) {Closing = true; while (CanDraw); finish();}
      	else while (CanDraw);
      	super.onPause();
      	GLView.onPause();
      }
      @Override
      public void onResume () {
      	super.onResume();
      	GLView.onResume();
      }
      public void FinalizeJNI () {
      	MessageJNI(AM_QUIT, 0, 0, 0);
      	CanDraw = false;
      }
      public void appclose () {
      	if (!Closing) {Closing = true; CanDraw = false; finish();}
      }
      public int fopeninput (String f) {
      	return FileMgr.FOpenInput(f);
      }
      public void fopenoutput (String f) {
      	FileMgr.FOpenOutput(f);
      }
      public void fsetpos (int pos) {
      	FileMgr.SetPos(pos);
      }
      public void fclose () {
      	FileMgr.FClose();
      }
      public int fread (byte[] buffer, int offset, int len) {
      	return FileMgr.Read(buffer, offset, len);
      }
      public void fwrite (byte[] buffer, int offset, int len) {
      	FileMgr.Write(buffer, offset, len);
      }
      public boolean fexists (String f) {
      	File file = GLView.getContext().getFileStreamPath(f);
      	return file.exists();
      }
      public int faopen (String f) {
      	int StreamSize = 0;
      	try {
  			AssetStream = AssetMgr.open(f, 1);
  			StreamSize = AssetStream.available();
  			AssetStream.mark(StreamSize);
  		} 
  		catch (IOException e) {}
  		return StreamSize;
  	}
      public void fasetpos (int pos) {
      	try {
  	    	AssetStream.reset();
  	    	AssetStream.skip(pos);
      	} 
  		catch (IOException e) {}
      }
      public void faclose () {
  		if (AssetStream != null) {
  			try {AssetStream.close();}
  			catch (IOException e) {} 
  			AssetStream = null;
  		}
  	}
      public int faread (byte[] buffer, int offset, int len) {
  		int BytesRead = 0;
      	try {
      		BytesRead = AssetStream.read(buffer, offset, len);
      	}
  		catch (IOException e) {};
  		return BytesRead;
  	}
      public int fontgetw () {
      	return FontWidth;
      }
      public int fontgeth () {
      	return FontHeight;
      }
      public int fontgetd (int[] buffer) {
      	FontBitmap.getPixels(buffer, 0, FontWidth, 0, 0, FontWidth, FontHeight);
      	return buffer.length;
      }
      public void fontmake (int size, int[] CharWidths, int[] CharHeights) {
      	Paint p = new Paint();
      	p.setColor(Color.WHITE);
      	p.setTextSize(size);
      	p.setFlags(Paint.ANTI_ALIAS_FLAG);
      	int MaxCharWidth = 0;
      	int MaxCharHeight = 0;
      	Rect Bounds = new Rect();
      	for (int i = 0; i < 256; i++) {
      		p.getTextBounds(Character.toChars(i), 0, 1, Bounds);
      		int w = Bounds.right - Bounds.left + 1;
      		int h = Bounds.bottom - Bounds.top + 1;
      		CharWidths[i] = w; CharHeights[i] = h;
      		if (MaxCharWidth < w) MaxCharWidth = w;
      		if (MaxCharHeight < h) MaxCharHeight = h;
      	}
      	int BmpWidth = MaxCharWidth * 16;
      	int BmpHeight = MaxCharHeight * 16;
      	int Width = 1; while (Width < BmpWidth) Width = Width << 1;
      	int Height = 1; while (Height < BmpHeight) Height = Height << 1;
      	FontWidth = Width; FontHeight = Height;
      	FontBitmap = Bitmap.createBitmap(Width, Height, Bitmap.Config.ARGB_4444);
      	Canvas c = new Canvas(FontBitmap);
      	Paint p1 = new Paint();
      	p1.setColor(Color.BLACK);
      	c.drawRect(0, 0, Width, Height, p1);
      	int CharWidth = Width / 16;
      	int CharHeight = Height / 16;
      	for (int i = 0; i < 256; i++) {
      		CharHeights[i] = MaxCharHeight;
      		int x = i % 16;
      		int y = i / 16;
      		int w = CharWidths[i];
      		int h = CharHeights[i];
      		c.drawText(
      			Character.toChars(i), 0, 1, 
      			x * CharWidth + (CharWidth - w) * 0.5f, 
      			y * CharHeight + CharHeight - (CharHeight - h) * 0.5f,
      			p
      		);
      	}
      }
      public class FileManager {
      	public int FM_STATE_IDLE = 0;
      	public int FM_STATE_READ = 1;
      	public int FM_STATE_WRITE = 2;
      	private FileOutputStream fos;
      	private FileInputStream fis;
      	private int State = FM_STATE_IDLE;
      	public int FOpenInput(String FileName) {
      		int FSize = 0;
      		try {
      			fis = openFileInput(FileName);
      			FSize = fis.available();
      			fis.mark(FSize);
      		}
      		catch (IOException e) {};
      		State = FM_STATE_READ;
      		return FSize;
      	}
      	public void FOpenOutput(String FileName) {
      		try {fos = openFileOutput(FileName, Context.MODE_PRIVATE);}
      		catch (IOException e) {};
      		State = FM_STATE_WRITE;
      	}
      	public void FClose() {
      		if (State == FM_STATE_READ) {
      			try {fis.close();}
      			catch (IOException e) {};
      		} else if (State == FM_STATE_WRITE) {
      			try {fos.close();}
      			catch (IOException e) {};
      		}
      		State = FM_STATE_IDLE;
      	}
      	public int Read(byte[] buffer, int offset, int len) {
      		int BytesRead = 0;
      		try {BytesRead = fis.read(buffer, offset, len);}
      		catch (IOException e) {};
      		return BytesRead;
      	}
      	public void Write(byte[] buffer, int offset, int len) {
      		try {fos.write(buffer, offset, len);}
  