public class Util
extends java.lang.Object
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static java.io.File |
createFile(java.lang.String filename)
Attempts to create a new file in an atomic way.
|
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 |
getPrivateInput(java.lang.String prompt)
Displays a prompt and then reads in private input from System.in.
|
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 boolean |
setOwnerAccessOnly(java.lang.String file)
Sets permissions on a given file to be only accessible by the current
user.
|
static java.lang.String |
unquote(java.lang.String str)
Dequotifies a specified string.
|
public static java.io.File createFile(java.lang.String filename)
throws java.lang.SecurityException,
java.io.IOException
filename - the name of file to create.java.lang.SecurityException - if the existing file cannot be deleted.java.io.IOException - if an I/O error occurred.public static boolean setOwnerAccessOnly(java.lang.String file)
setFilePermissions(String, int)public static boolean setFilePermissions(java.lang.String file,
int mode)
file - the file to set the permissions of.mode - the Unix style permissions.public static boolean destroy(java.lang.String file)
file - file to removepublic static boolean destroy(java.io.File file)
file - file to removepublic static java.lang.String getInput(java.lang.String prompt)
prompt - the prompt to be displayedString the input read in (entered after the prompt)public static java.lang.String getPrivateInput(java.lang.String prompt)
prompt - the prompt to be displayedString the input read in (entered after the prompt)public static java.lang.String quote(java.lang.String str)
str - the string to quotifypublic static java.lang.String unquote(java.lang.String str)
throws java.lang.Exception
str - the string to dequotify.java.lang.Exceptionpublic static java.lang.String decode(java.lang.String s)
String, each character is examined in turn:
%xy", where xy is the two-digit
hexadecimal representation of the lower 8-bits of the character.
public static java.lang.String formatTimeSec(long time)
public static java.lang.String getLocalHostAddress()
InetAddress class. In case the lookup
fails, the address 127.0.0.1 is returned.Copyright © 2013. All Rights Reserved.