|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
org.globus.util
Class Util
java.lang.Object | +--org.globus.util.Util
- public class Util
- extends Object
| Constructor Summary | |
Util()
|
|
| Method Summary | |
static String |
decode(String s)
The function decodes URL-encoded strings into a regular string. |
static boolean |
destroy(File file)
Overwrites the contents of the file with a random string and then deletes the file. |
static boolean |
destroy(String file)
Overwrites the contents of the file with a random string and then deletes the file. |
static String |
formatTimeSec(long time)
Generates string representation of given time specified as long. |
static String |
getInput(String prompt)
Displays a prompt and then reads in the input from System.in. |
static String |
getLocalHostAddress()
Returns the ip address of the local machine. |
static String |
quote(String str)
Quotifies a specified string. |
static boolean |
setFilePermissions(String file,
int mode)
Sets permissions on a given file. |
static String |
unquote(String str)
Dequotifies a specified string. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
Util
public Util()
| Method Detail |
setFilePermissions
public static boolean setFilePermissions(String file, int mode)
- Sets permissions on a given file. The permissions
are set using the chmod command and will only
work on Unix machines.
Chmod command must be in the path.
- Parameters:
file- the file to set the permissions of.mode- the Unix style permissions.- Returns:
- true, if change was successful, otherwise false. It can return false, in many instances, e.g. when file does not exits, when chmod is not found, or other error occurs.
destroy
public static boolean destroy(String file)
- Overwrites the contents of the file with a random
string and then deletes the file.
- Parameters:
file- file to remove
destroy
public static boolean destroy(File file)
- Overwrites the contents of the file with a random
string and then deletes the file.
- Parameters:
file- file to remove
getInput
public static String getInput(String prompt)
- Displays a prompt and then reads in the input from System.in.
- Parameters:
prompt- the prompt to be displayed- Returns:
Stringthe input read in (entered after the prompt)
quote
public static String quote(String str)
- Quotifies a specified string.
The entire string is encompassed by double quotes and each
" is replaced with \", \ is replaced with \\.
- Parameters:
str- the string to quotify- Returns:
- quotified and escaped string
unquote
public static String unquote(String str) throws Exception
- Dequotifies a specified string.
The quotes are removed and each \" is replaced with " and
each \\ is replaced with \.
- Parameters:
str- the string to dequotify.- Returns:
- unquotified string.
decode
public static String decode(String s)
- The function decodes URL-encoded strings into a regular string.
This function is mostly copied from the Java source code.
To convert to a
String, each character is examined in turn:- The remaining characters are represented by 3-character
strings which begin with the percent sign,
"
%xy", where xy is the two-digit hexadecimal representation of the lower 8-bits of the character.
- The remaining characters are represented by 3-character
strings which begin with the percent sign,
"
formatTimeSec
public static String formatTimeSec(long time)
- Generates string representation of given time specified as long. The format is: [days][,][h][,][min][,][sec]
getLocalHostAddress
public static String getLocalHostAddress()
- Returns the ip address of the local machine.
If the 'ip' system property is defined it is returned,
otherwise, the local ip address is lookup using the
InetAddressclass. In case the lookup fails, the address 127.0.0.1 is returned.- Returns:
- local ip address
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||