public static Long parseStringAsBytes(String property) { if (isEmpty(property)) return null; // Find first non-digit char: int pos = 0; while (pos < property.length() && Character.isDigit(property.charAt(pos))) pos++; String prefix = property.substring(0, pos); long number = Long.parseLong(prefix); String suffix = pos < property.length() ? property.substring(pos) : null; int factor = parseMemoryUnit(suffix); return number * factor; }