org.knopflerfish.ant.taskdefs.bundle
Class Util
java.lang.Object
|
+--org.knopflerfish.ant.taskdefs.bundle.Util
- public class Util
- extends java.lang.Object
Misc static utility code.
|
Constructor Summary |
Util()
|
|
Method Summary |
static java.lang.String |
getRelativePath(java.io.File fromFile,
java.io.File toFile)
|
static java.lang.String |
load(java.lang.String fileOrURL)
Load entire contents of a file or URL into a string. |
static java.lang.String |
loadFile(java.lang.String fname)
|
static byte[] |
loadURL(java.net.URL url)
|
static java.util.Set |
makeSetFromStringList(java.lang.String s)
Create a Set from a comma-separated string. |
static java.lang.String |
replace(java.lang.String s,
java.lang.String v1,
java.lang.String v2)
Replace all occurences of a substring with another string. |
static java.lang.String[] |
splitwords(java.lang.String s)
Split a string into words separated by whitespace
SPACE | TAB | NEWLINE | CR
Citation chars '"' may be used to group words
with embedded whitespace. |
static java.lang.String[] |
splitwords(java.lang.String s,
java.lang.String whiteSpace,
char citchar)
Split a string into words separated by whitespace. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Util
public Util()
loadURL
public static byte[] loadURL(java.net.URL url)
throws java.io.IOException
loadFile
public static java.lang.String loadFile(java.lang.String fname)
throws java.io.IOException
load
public static java.lang.String load(java.lang.String fileOrURL)
throws java.io.IOException
- Load entire contents of a file or URL into a string.
makeSetFromStringList
public static java.util.Set makeSetFromStringList(java.lang.String s)
- Create a Set from a comma-separated string.
getRelativePath
public static java.lang.String getRelativePath(java.io.File fromFile,
java.io.File toFile)
replace
public static java.lang.String replace(java.lang.String s,
java.lang.String v1,
java.lang.String v2)
- Replace all occurences of a substring with another string.
If no replacements are needed, the methods returns the original string.
- Parameters:
s - Source string which will be scanned and modified.
If null, return nullv1 - String to be replaced with v2.
If null, return original string.v2 - String replacing v1.
If null, return original string.- Returns:
- Modified string.
splitwords
public static java.lang.String[] splitwords(java.lang.String s)
- Split a string into words separated by whitespace
SPACE | TAB | NEWLINE | CR
Citation chars '"' may be used to group words
with embedded whitespace.
splitwords
public static java.lang.String[] splitwords(java.lang.String s,
java.lang.String whiteSpace,
char citchar)
- Split a string into words separated by whitespace.
Citation chars '"' may be used to group words with embedded
whitespace.
- Parameters:
s - String to split.whiteSpace - whitespace to use for splitting. Any of the
characters in the whiteSpace string are considered
whitespace between words and will be removed
from the result.citchar - citation char used for enclosing words containing
whitespace