|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
org.globus.util
Class Util
java.lang.Object | +--org.globus.util.Util
- public class Util
- extends java.lang.Object
| Constructor Summary | |
Util()
|
|
| Method Summary | |
static java.lang.String |
decode(java.lang.String s)
The function decodes URL-encoded strings into a regular string. |
static boolean |
destroy(java.io.File file)
Overwrites the contents of the file with a random string and then deletes the file. |
static boolean |
destroy(java.lang.String file)
Overwrites the contents of the file with a random string and then deletes the file. |
static java.lang.String |
formatTimeSec(long time)
Generates string representation of given time specified as long. |
static java.lang.String |
getInput(java.lang.String prompt)
Displays a prompt and then reads in the input from System.in. |
static java.lang.String |
getLocalHostAddress()
Returns the ip address of the local machine. |
static java.lang.String |
quote(java.lang.String str)
Quotifies a specified string. |
static boolean |
setFilePermissions(java.lang.String file,
int mode)
Sets permissions on a given file. |
static java.lang.String |
unquote(java.lang.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(java.lang.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(java.lang.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(java.io.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 java.lang.String getInput(java.lang.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 java.lang.String quote(java.lang.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 java.lang.String unquote(java.lang.String str)
throws java.lang.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.
java.lang.Exception
decode
public static java.lang.String decode(java.lang.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 java.lang.String formatTimeSec(long time)
- Generates string representation of given time specified
as long. The format is: [days][,][h][,][min][,][sec]
getLocalHostAddress
public static java.lang.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: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||