Revision 1598
Added by Jing Tao over 21 years ago
src/edu/ucsb/nceas/metacat/MetaCatUtil.java | ||
---|---|---|
604 | 604 |
} |
605 | 605 |
return result; |
606 | 606 |
} |
607 |
|
|
608 |
/** A method to replace whitespace in url*/ |
|
609 |
public static String replaceWhiteSpaceForURL(String urlHasWhiteSpace) |
|
610 |
{ |
|
611 |
StringBuffer newUrl = new StringBuffer(); |
|
612 |
String whiteSpaceReplace ="%20"; |
|
613 |
if (urlHasWhiteSpace == null || urlHasWhiteSpace.trim().equals("")) |
|
614 |
{ |
|
615 |
return null; |
|
616 |
} |
|
607 | 617 |
|
618 |
for (int i=0; i<urlHasWhiteSpace.length(); i++) |
|
619 |
{ |
|
620 |
char ch = urlHasWhiteSpace.charAt(i); |
|
621 |
if ( !Character.isWhitespace(ch)) |
|
622 |
{ |
|
623 |
newUrl.append(ch); |
|
624 |
} |
|
625 |
else |
|
626 |
{ |
|
627 |
//it is white sapce, replace it by %20 |
|
628 |
newUrl = newUrl.append(whiteSpaceReplace); |
|
629 |
} |
|
630 |
|
|
631 |
}//for |
|
632 |
MetaCatUtil.debugMessage("The new string without space is:"+ |
|
633 |
newUrl.toString(), 35); |
|
634 |
return newUrl.toString(); |
|
635 |
|
|
636 |
}// replaceWhiteSpaceForUR |
|
637 |
|
|
608 | 638 |
} |
Also available in: Unified diff
Add a new method to replace whtie space by %20 in url string.