double (final String sizeStr) { int slashPos = sizeStr.indexOf('/'); if (slashPos >= 0) { int spacePos = sizeStr.indexOf(' '); int intPart = Integer.parseInt(sizeStr.substring(0, spacePos)); double numerator = Double.parseDouble(sizeStr.substring(spacePos + 1, slashPos)); double denominator = Double.parseDouble(sizeStr.substring(slashPos + 1)); return intPart + numerator / denominator; } return Integer.parseInt(sizeStr); }