long toFileSize(String value) { if (value == null) return DEFAULT_MAX_FILE_SIZE; String s = value.trim().toUpperCase(); long multiplier = 1; int index; if ((index = s.indexOf("KB")) != -1) { multiplier = 1024; s = s.substring(0, index); } else if ((index = s.indexOf("MB")) != -1) { multiplier = 1024 * 1024; s = s.substring(0, index); } else if ((index = s.indexOf("GB")) != -1) { multiplier = 1024 * 1024 * 1024; s = s.substring(0, index); } if (s != null) { try { return Long.valueOf(s).longValue() * multiplier; } catch (NumberFormatException e) { addError("[" + s + "] is not in proper int format. Please refer to " + SEE_SIZE_FORMAT); addError("[" + value + "] not in expected format.", e); } } return DEFAULT_MAX_FILE_SIZE; } }
long toFileSize(String value) { if (value == null) return DEFAULT_MAX_FILE_SIZE; String s = value.trim().toUpperCase(); long multiplier = 1; int index; if ((index = s.indexOf("KB")) != -1) { multiplier = 1024; s = s.substring(0, index); } else if ((index = s.indexOf("MB")) != -1) { multiplier = 1024 * 1024; s = s.substring(0, index); } else if ((index = s.indexOf("GB")) != -1) { multiplier = 1024 * 1024 * 1024; s = s.substring(0, index); } if (s != null) { try { return Long.valueOf(s).longValue() * multiplier; } catch (NumberFormatException e) { addError("[" + s + "] is not in proper int format. Please refer to " + SEE_SIZE_FORMAT); addError("[" + value + "] not in expected format.", e); } } return DEFAULT_MAX_FILE_SIZE; } }
long toFileSize(String value) { if (value == null) return DEFAULT_MAX_FILE_SIZE; String s = value.trim().toUpperCase(); long multiplier = 1; int index; if ((index = s.indexOf("KB")) != -1) { multiplier = 1024; s = s.substring(0, index); } else if ((index = s.indexOf("MB")) != -1) { multiplier = 1024 * 1024; s = s.substring(0, index); } else if ((index = s.indexOf("GB")) != -1) { multiplier = 1024 * 1024 * 1024; s = s.substring(0, index); } if (s != null) { try { return Long.valueOf(s).longValue() * multiplier; } catch (NumberFormatException e) { addError("[" + s + "] is not in proper int format. Please refer to " + SEE_SIZE_FORMAT); addError("[" + value + "] not in expected format.", e); } } return DEFAULT_MAX_FILE_SIZE; } }
long toFileSize(String value) { if (value == null) return DEFAULT_MAX_FILE_SIZE; String s = value.trim().toUpperCase(); long multiplier = 1; int index; if ((index = s.indexOf("KB")) != -1) { multiplier = 1024; s = s.substring(0, index); } else if ((index = s.indexOf("MB")) != -1) { multiplier = 1024 * 1024; s = s.substring(0, index); } else if ((index = s.indexOf("GB")) != -1) { multiplier = 1024 * 1024 * 1024; s = s.substring(0, index); } if (s != null) { try { return Long.valueOf(s).longValue() * multiplier; } catch (NumberFormatException e) { addError("[" + s + "] is not in proper int format. Please refer to " + SEE_SIZE_FORMAT); addError("[" + value + "] not in expected format.", e); } } return DEFAULT_MAX_FILE_SIZE; } }
long toFileSize(String value) { if (value == null) return DEFAULT_MAX_FILE_SIZE; String s = value.trim().toUpperCase(); long multiplier = 1; int index; if ((index = s.indexOf("KB")) != -1) { multiplier = 1024; s = s.substring(0, index); } else if ((index = s.indexOf("MB")) != -1) { multiplier = 1024 * 1024; s = s.substring(0, index); } else if ((index = s.indexOf("GB")) != -1) { multiplier = 1024 * 1024 * 1024; s = s.substring(0, index); } if (s != null) { try { return Long.valueOf(s).longValue() * multiplier; } catch (NumberFormatException e) { addError("[" + s + "] is not in proper int format. Please refer to " + SEE_SIZE_FORMAT); addError("[" + value + "] not in expected format.", e); } } return DEFAULT_MAX_FILE_SIZE; } }