Author: kevj
Date: Tue Dec 12 18:36:23 2006
New Revision: 486465
URL: http://svn.apache.org/viewvc?view=rev&rev=486465
Log:
-remove Java1.4 specific methods from parseHumanSizes
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java?view=diff&rev=486465&r1=486464&r2=486465
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java Tue Dec
12 18:36:23 2006
@@ -201,8 +201,8 @@
final long GIGABYTE = MEGABYTE * 1024;
final long TERABYTE = GIGABYTE * 1024;
final long PETABYTE = TERABYTE * 1024;
- String regex = "\\d+[K|M|G|T|P]";
- if(humanSize.matches(regex)) {
+ //last character isn't a digit
+ if(!Character.isDigit(humanSize.charAt(humanSize.length()-1))) {
char c = humanSize.charAt(humanSize.length()-1);
long value = Long.valueOf(humanSize.substring(0,
humanSize.length()-1)).longValue();
switch (c) {
@@ -219,10 +219,8 @@
default:
return value;
}
- } else if(humanSize.matches("\\d+")) {
- return Long.parseLong(humanSize);
} else {
- throw new Exception("Couldn't parse string: "+humanSize);
+ return Long.parseLong(humanSize);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]