Here you can find the source of normalizeMemoryMeasure(String memory)
Parameter | Description |
---|---|
memory | Manifest memory measurement. |
public static int normalizeMemoryMeasure(String memory)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 IBM Corporation and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * // w w w . j a va 2s . c om * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ public class Main { /** * Normalizes the string memory measurement to a MB integer value. * @param memory Manifest memory measurement. * @return Normalized MB integer value. */ public static int normalizeMemoryMeasure(String memory) { if (memory.toLowerCase().endsWith("m")) //$NON-NLS-1$ return Integer.parseInt(memory.substring(0, memory.length() - 1)); if (memory.toLowerCase().endsWith("mb")) //$NON-NLS-1$ return Integer.parseInt(memory.substring(0, memory.length() - 2)); if (memory.toLowerCase().endsWith("g")) //$NON-NLS-1$ return (1024 * Integer.parseInt(memory.substring(0, memory.length() - 1))); if (memory.toLowerCase().endsWith("gb")) //$NON-NLS-1$ return (1024 * Integer.parseInt(memory.substring(0, memory.length() - 2))); /* return default memory value, i.e. 1024 MB */ return 1024; } }