public class SoftwareServerUtility extends Object
Constructor and Description |
---|
SoftwareServerUtility() |
Modifier and Type | Method and Description |
---|---|
static String |
addAuthentication(String url,
String authentication)
Add authentication to a URL.
|
static String |
executeAndWait(String command,
int max_runtime)
Execute the given command.
|
static String |
executeAndWait(String command,
int max_runtime,
boolean HANDLE_OUTPUT,
boolean SHOW_OUTPUT)
Execute the given command.
|
static boolean |
existsURL_bak(String url)
Deprecated.
|
static boolean |
existsURL(String url)
Check if the specified URL exists.
|
static long |
getFileSize(String filename)
Get the size of a local or remote file.
|
static String |
getFileSizeHR(String filename)
Get the size of a local or remote file in a human readable form.
|
static String |
getTimeStamp()
Get the current date and time (useful for logs, is thread safe).
|
static String |
humanReadableBytes(long bytes)
Get bytes in human readable form.
|
static void |
main(String[] args)
A main for debug purposes.
|
static void |
print(String string,
String filename)
Append a string to a file.
|
static void |
println(String string,
String filename)
Append a line to a file.
|
static String |
readURL(String url,
String type)
Read the contents of the specified URL and store it in a string.
|
static void |
setDefaultAuthentication(String authentication)
Set default authentication for HTTP requests.
|
@Deprecated public static boolean existsURL_bak(String url)
url
- the URL to checkpublic static boolean existsURL(String url)
url
- the URL to checkpublic static String readURL(String url, String type)
url
- the URL to readtype
- the accepted content typepublic static long getFileSize(String filename)
filename
- the file name or URLpublic static String humanReadableBytes(long bytes)
bytes
- the number of bytespublic static String getFileSizeHR(String filename)
filename
- the file name or URLpublic static String executeAndWait(String command, int max_runtime, boolean HANDLE_OUTPUT, boolean SHOW_OUTPUT)
command
- the commandmax_runtime
- the maximum allowed time to run (in milli-seconds, -1 indicates forever)HANDLE_OUTPUT
- true if the process output should be handledSHOW_OUTPUT
- true if the process output should be shownpublic static String executeAndWait(String command, int max_runtime)
command
- the commandmax_runtime
- the maximum allowed time to run (in milli-seconds, -1 indicates forever)public static String addAuthentication(String url, String authentication)
url
- a URLauthentication
- the "username:password"public static void setDefaultAuthentication(String authentication)
authentication
- the "username:password"public static void print(String string, String filename)
string
- the text to append to the filefilename
- the file to append topublic static void println(String string, String filename)
string
- the line to append to the filefilename
- the file to append topublic static String getTimeStamp()
public static void main(String[] args)
args
- the command line argumentsCopyright © 2015. All rights reserved.