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

Constructor Index

 o Util()

Method Index

 o bug(Exception)
 o bug(String)
record that we have hit a program bug!!!
 o capitalise(String)
capitalise a String (whatever the starting case)
 o deQuote(String)
remove balanced quotes from ends of (trimmed) string, else no action
 o freeMemory(long)
runs the grabage collector if memory drops below mem.
 o getCause(Exception)
Recursive exception build up long strings, or which only the end is often useful.
 o getIntFromHex(String)
horrid, but I couldn't find if Java reads hex.
 o getPWDName()
get current directory
 o getURLContent(String)
 o getURLProtocol(String)
get protocol from a potential URL; if none, returns ""
 o isReadableFile(String)
is a file readable (must also exist!)
 o locateClassDirectory(String)
locate CLASS directory which contains a given class.
 o longFromDate(Date)
get a long from a Date (should be easy, but isn't)
 o main(String[])
tests File
 o outputToFile(String, File)
output a single String (which could contain \n) to file
 o printf(int, int)
until printf comes along...
 o prompt(String)
offers a prompt on stdout and reads the input until CR
 o quoteConcatenate(String[])
concatenate strings into quote-separated string
 o readByteArray(String)
 o spaces(int)
make a String of a given number of spaces
 o substituteStrings(String, String[], String[])
make substitutions in a string

Constructors

 o Util
  public Util()

Methods

 o prompt
  public static String prompt(String prompt)
offers a prompt on stdout and reads the input until CR
 o spaces
  public static String spaces(int nspace)
make a String of a given number of spaces
 o deQuote
  public static String deQuote(String s)
remove balanced quotes from ends of (trimmed) string, else no action
 o quoteConcatenate
  public static String quoteConcatenate(String s[])
concatenate strings into quote-separated string
 o bug
  public static void bug(String s)
record that we have hit a program bug!!!
 o bug
  public static void bug(Exception e)
 o printf
  public static String printf(int i,
                              int ndec)
until printf comes along...
 o 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!!

 o longFromDate
  public static long longFromDate(Date d)
get a long from a Date (should be easy, but isn't)
 o isReadableFile
  public static boolean isReadableFile(String f)
is a file readable (must also exist!)
 o getPWDName
  public static String getPWDName()
get current directory
 o substituteStrings
  public static String substituteStrings(String s,
                                         String oldSubstrings[],
                                         String newSubstrings[])
make substitutions in a string
 o 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
 o capitalise
  public static String capitalise(String s)
capitalise a String (whatever the starting case)
 o getURLProtocol
  public static String getURLProtocol(String urlString)
get protocol from a potential URL; if none, returns ""
 o 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
 o 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
 o main
  public static void main(String args[])
tests File
 o getURLContent
  public static StringList getURLContent(String urlName) throws MalformedURLException, IOException
 o getIntFromHex
  public static int getIntFromHex(String hex)
horrid, but I couldn't find if Java reads hex. Crude; no exceptions thrown
 o readByteArray
  public static byte[] readByteArray(String filename) throws FileNotFoundException, IOException

All Packages  Class Hierarchy  This Package  Previous  Next  Index