Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.LinkedHashMap; import java.util.Map; import android.content.Context; import android.util.Log; import android.widget.Toast; public class Main { public static final boolean DEBUG = true; static final String LOG_TAG = "crin"; private static Toast curToast = null; private static Context curContext = null; private static Map<String, int[]> courses = new LinkedHashMap<String, int[]>(); /** * Parse basic course data. */ private static void parseCourseData(final String line) throws Exception { final String[] nameTokens = line.split(":"); final String courseName = nameTokens[0].trim(); final int holeCount = Integer.parseInt(nameTokens[1].trim()); final String coursePars = nameTokens[2].trim(); v(" course name: " + courseName); v(" course hole counts: " + holeCount); v(" course pars: " + coursePars); final String[] parStrings = coursePars.split(","); if (holeCount != parStrings.length) { e("The specified hole count (" + holeCount + ") doesn't match the number of pars listed: (" + parStrings.length + "); aborting"); toast("The specified hole count (" + holeCount + ") doesn't match the number of pars listed: (" + parStrings.length + "); aborting"); throw new Exception("Bad hole count"); } final int[] pars = new int[holeCount]; for (int i = 0; i < holeCount; ++i) { pars[i] = Integer.parseInt(parStrings[i]); } courses.put(courseName, pars); } static final void v(String mesg) { if (DEBUG) { Log.v(LOG_TAG, mesg); } } static final void e(String mesg) { Log.e(LOG_TAG, mesg); } static final void toast(String mesg) { if (null != curToast) { curToast.cancel(); } curToast = Toast.makeText(curContext, mesg, Toast.LENGTH_SHORT); curToast.show(); } }