Package org.jclouds.util
Class Strings2
- java.lang.Object
-
- org.jclouds.util.Strings2
-
public class Strings2 extends Object
-
-
Constructor Summary
Constructors Constructor Description Strings2()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isCidrFormat(String in)
static boolean
isIPv6CIDR(String in)
static String
replaceTokens(String input, com.google.common.collect.Multimap<String,?> tokenValues)
static String
replaceTokens(String input, Map<String,String> replacements)
replaces tokens that are expressed as{token}
static InputStream
toInputStream(String in)
static String
toStringAndClose(InputStream input)
static String
urlDecode(String in)
url decodes the input param, if set.static String
urlEncode(String in, char... skipEncode)
Web browsers do not always handle '+' characters well, use the well-supported '%20' instead.static String
urlEncode(String in, Iterable<Character> skipEncode)
-
-
-
Method Detail
-
urlEncode
public static String urlEncode(String in, char... skipEncode)
Web browsers do not always handle '+' characters well, use the well-supported '%20' instead.
-
isCidrFormat
public static boolean isCidrFormat(String in)
-
isIPv6CIDR
public static boolean isIPv6CIDR(String in)
-
urlDecode
public static String urlDecode(@Nullable String in)
url decodes the input param, if set.- Parameters:
in
- nullable- Returns:
- null if input was null
- Throws:
IllegalStateException
- if encoding isn'tUTF-8
-
toStringAndClose
public static String toStringAndClose(InputStream input) throws IOException
- Throws:
IOException
-
toInputStream
public static InputStream toInputStream(String in)
-
replaceTokens
public static String replaceTokens(String input, Map<String,String> replacements)
replaces tokens that are expressed as{token}
ex. if input is "hello {where}"
and replacements is "where" -> "world"
then replaceTokens returns "hello world"- Parameters:
input
- source to replacereplacements
- token/value pairs
-
-