Class pmr.util.Util
All Packages Class Hierarchy This Package Previous Next Index
Class pmr.util.Util
java.lang.Object
|
+----pmr.util.Util
- public class Util
- extends Object
A number of miscellaneous tools.
- Author:
- (C) P. Murray-Rust, 1996
-
Util()
-
-
bug(Exception)
-
-
bug(String)
- record that we have hit a program bug!!!
-
capitalise(String)
- capitalise a String (whatever the starting case)
-
deQuote(String)
- remove balanced quotes from ends of (trimmed) string, else no action
-
freeMemory(long)
- runs the grabage collector if memory drops below mem.
-
getCause(Exception)
- Recursive exception build up long strings, or which only the end is often
useful.
-
getIntFromHex(String)
- horrid, but I couldn't find if Java reads hex.
-
getPWDName()
- get current directory
-
getURLContent(String)
-
-
getURLProtocol(String)
- get protocol from a potential URL; if none, returns ""
-
isReadableFile(String)
- is a file readable (must also exist!)
-
locateClassDirectory(String)
- locate CLASS directory which contains a given class.
-
longFromDate(Date)
- get a long from a Date (should be easy, but isn't)
-
main(String[])
- tests File
-
outputToFile(String, File)
- output a single String (which could contain \n) to file
-
printf(int, int)
- until printf comes along...
-
prompt(String)
- offers a prompt on stdout and reads the input until CR
-
quoteConcatenate(String[])
- concatenate strings into quote-separated string
-
readByteArray(String)
-
-
spaces(int)
- make a String of a given number of spaces
-
substituteStrings(String, String[], String[])
- make substitutions in a string
Util
public Util()
prompt
public static String prompt(String prompt)
- offers a prompt on stdout and reads the input until CR
spaces
public static String spaces(int nspace)
- make a String of a given number of spaces
deQuote
public static String deQuote(String s)
- remove balanced quotes from ends of (trimmed) string, else no action
quoteConcatenate
public static String quoteConcatenate(String s[])
- concatenate strings into quote-separated string
bug
public static void bug(String s)
- record that we have hit a program bug!!!
bug
public static void bug(Exception e)
printf
public static String printf(int i,
int ndec)
- until printf comes along...
locateClassDirectory
public static String locateClassDirectory(String className)
- locate CLASS directory which contains a given class. recursively
descends from all the elements of CLASSPATH until it finds a file of
the form MYCLASS.class. This is assumed to be case-insensitive; I don't know
what the extensions are on other machines than UNIX.
A class like PLAY
could be found in /usr/local/java/classes/local/sgml/play/PLAY.class.
or CML in /usr/local/java/classes/pmr/cml/CML.class
Experimental!!
longFromDate
public static long longFromDate(Date d)
- get a long from a Date (should be easy, but isn't)
isReadableFile
public static boolean isReadableFile(String f)
- is a file readable (must also exist!)
getPWDName
public static String getPWDName()
- get current directory
substituteStrings
public static String substituteStrings(String s,
String oldSubstrings[],
String newSubstrings[])
- make substitutions in a string
outputToFile
public static void outputToFile(String s,
File f) throws IOException
- output a single String (which could contain \n) to file
- Throws: IOException
- an output error occured
capitalise
public static String capitalise(String s)
- capitalise a String (whatever the starting case)
getURLProtocol
public static String getURLProtocol(String urlString)
- get protocol from a potential URL; if none, returns ""
getCause
public static String getCause(Exception e)
- Recursive exception build up long strings, or which only the end is often
useful. return just the error message
freeMemory
public static void freeMemory(long mem)
- runs the grabage collector if memory drops below mem. (I use a value
of 300000 - your mileage may vary). Potentially used in loops for processing
input and creation of objects
main
public static void main(String args[])
- tests File
getURLContent
public static StringList getURLContent(String urlName) throws MalformedURLException, IOException
getIntFromHex
public static int getIntFromHex(String hex)
- horrid, but I couldn't find if Java reads hex. Crude; no exceptions thrown
readByteArray
public static byte[] readByteArray(String filename) throws FileNotFoundException, IOException
All Packages Class Hierarchy This Package Previous Next Index