Java tutorial
//package com.java2s; /** * Mupen64PlusAE, an N64 emulator for the Android platform * * Copyright (C) 2013 Paul Lamb * * This file is part of Mupen64PlusAE. * * Mupen64PlusAE is free software: you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * Mupen64PlusAE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with Mupen64PlusAE. If * not, see <http://www.gnu.org/licenses/>. * * Authors: xperia64 */ import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import android.text.TextUtils; import android.util.Log; public class Main { public static BufferedReader getCheatsLocation(String regularExpression, String filename) { // Make sure a file was specified in the constructor if (TextUtils.isEmpty(filename)) { Log.e("CheatFile", "Filename not specified in method reload()"); return null; } BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(filename)); boolean done = false; String fullLine = null; while (!done && (fullLine = reader.readLine()) != null) { if (fullLine.startsWith("crc ")) { // Start of the next cheat section, return done = fullLine.substring(4).matches(regularExpression); } } if (fullLine != null) { Log.i("CheatUtils", fullLine); } } catch (FileNotFoundException e) { Log.e("CheatFile", "Could not open " + filename); return null; } catch (IOException e) { Log.e("CheatFile", "Could not read " + filename); return null; } return reader; } }