Code example for MatchResult

Methods: group, groupCount

0
	private static long findLongByMatchInMemInfo(final String pPattern)
			throws Exception { 
		final Scanner scanner = scannerFile(MEMINFO_PATH);
		final MatchResult matchResult = scanner.match();
		if (scanner.findWithinHorizon(pPattern, 1000) != null
				&& matchResult.groupCount() > 0)
			return Long.parseLong(matchResult.group(1));
		else 
			throw new Exception();
	} 
 
	public static long getFreeMemory() throws Exception { 
		return findLongByMatchInMemInfo(getPatternValueKb("MemFree")); 
	} 
 
}