Code example for Scanner

Methods: close, next

0
	private static int readVersionFile() { 
		if (! versionFile.exists()) return 0;
		Scanner in;
		int versionCode = 0;
		try { 
			in = new Scanner(versionFile);
			versionCode = Integer.parseInt(in.next());
			in.close();
		} catch (Exception e) {
			LilDebi.log.append("Can't read app version file: " + e.getLocalizedMessage() + "\n");
		} 
		return versionCode;
	} 
 
	private static void writeVersionFile(Context context) {
		try { 
			PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
			FileOutputStream fos = new FileOutputStream(versionFile);
			OutputStreamWriter out = new OutputStreamWriter(fos);
			out.write(String.valueOf(pInfo.versionCode) + "\n");
			out.close();