Utility (PMII - Principia Mathematica II)
Keywords: com.meyling.principia.io.Utility class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Hilbert II - JAVA-Packages - Principia Mathematica II
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.meyling.principia.io
Class Utility

    java.lang.Object
      com.meyling.principia.io.Utility

public class Utility
extends Object

A collection of usefull static methods.

Version:
  $Revision: 1.16 $
Author:
  Michael Meyling

Method Summary
`static String` | `createRelativePath(File orgin, File next)` Create relative address from `orgin` to `next`.
`static boolean` | `deleteDir(File dir)`
`static String` | `getClassName(Class clazz)` Get non qualified class name.
`static StringBuffer` | `getSpaces(int length)` Get amount of spaces.
`static File` | `getUserHomeDirectory()`
`static boolean` | `isLetterDigitString(String text)` Tests if given `String` begins with a letter and contains only letters and digits.
`static void` | `loadFile(File file, StringBuffer buffer)` Reads contents of a file into a string buffer.
`static String` | `loadFile(String filename)` Reads a file and returns the contents as a `String`.
`static void` | `loadFile(String filename, StringBuffer buffer)` Reads contents of a file into a string buffer.
`static void` | `loadStream(InputStream in, StringBuffer buffer)` Reads contents of a stream into a string buffer.
`static void` | `printAllSystemProperties()`
`static String` | `quote(String unquoted)` Quotes a `String`.
`static void` | `replace(StringBuffer text, String search, String replace)` Replaces all occurences of `search` in `text` by `replace` and returns the result.
`static String` | `replace(String text, String search, String replace)` Replaces all occurences of `search` in `text` by `replace` and returns the result.
`static void` | `saveFile(File file, String text)` Saves a `String` in a file.
`static void` | `saveFile(File file, StringBuffer text)` Saves a `StringBuffer` in a file.
`static void` | `saveFile(String filename, String text)` Saves a `String` in a file.
`static void` | `saveFile(String filename, StringBuffer text)` Saves a `StringBuffer` in a file.
`static void` | `waitln()` Waits til a '\n' was read from System.in.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### loadFile

    public static final String loadFile(String filename)
                                 throws IOException

  Reads a file and returns the contents as a `String`.

  Parameters:
    `filename` - name of the file (could include path)
  Returns:
    contents of file
  Throws:
    `IOException` - if a file exception occured

### loadFile

    public static final void loadFile(String filename,
                                      StringBuffer buffer)
                               throws IOException

  Reads contents of a file into a string buffer.

  Parameters:
    `filename` - name of the file (could include path)
    `buffer` - buffer to fill with file contents
  Throws:
    `IOException` - if a file exception occured

### loadStream

    public static final void loadStream(InputStream in,
                                        StringBuffer buffer)
                                 throws IOException

  Reads contents of a stream into a string buffer.

  Parameters:
    `in` - this stream will be loaded
    `buffer` - buffer to fill with file contents
  Throws:
    `IOException` - if a file exception occured

### loadFile

    public static final void loadFile(File file,
                                      StringBuffer buffer)
                               throws IOException

  Reads contents of a file into a string buffer.

  Parameters:
    `file` - this file will be loaded.
    `buffer` - buffer to fill with file contents.
  Throws:
    `IOException` - a file exception occured.

### saveFile

    public static final void saveFile(String filename,
                                      String text)
                               throws IOException

  Saves a `String` in a file.

  Parameters:
    `filename` - name of the file (could include path).
    `text` - data to save in the file.
  Throws:
    `IOException` - a file exception occured.

### saveFile

    public static final void saveFile(String filename,
                                      StringBuffer text)
                               throws IOException

  Saves a `StringBuffer` in a file.

  Parameters:
    `filename` - name of the file (could include path).
    `text` - data to save in the file.
  Throws:
    `IOException` - if a file exception occured.

### saveFile

    public static final void saveFile(File file,
                                      StringBuffer text)
                               throws IOException

  Saves a `StringBuffer` in a file.

  Parameters:
    `text` - data to save in the file.
  Throws:
    `IOException` - if a file exception occured.

### saveFile

    public static final void saveFile(File file,
                                      String text)
                               throws IOException

  Saves a `String` in a file.

  Parameters:
    `file` - file.
    `text` - data to save in the file.
  Throws:
    `IOException` - a file exception occured.

### quote

    public static final String quote(String unquoted)

  Quotes a `String`. If no quotes exist in the `String`, a quote character is appended at the beginning and the end of the `String`.

  Parameters:
    `unquoted` - the ungequoted" `String`
  Returns:
    quoted `String`
  Throws:
    `NullPointerException` - if `unquoted == null`

### isLetterDigitString

    public static final boolean isLetterDigitString(String text)

  Tests if given `String` begins with a letter and contains only letters and digits.

  Parameters:
    `text` - test this
  Returns:
    is `text` only made of letters and digits and has a leading letter?
  Throws:
    `NullPointerException` - if `text == null`

### replace

    public static final String replace(String text,
                                       String search,
                                       String replace)

  Replaces all occurences of `search` in `text` by `replace` and returns the result.

  Parameters:
    `text` - text to work on
    `search` - replace this text by `replace`
    `replace` - replacement for `search`
  Returns:
    resulting string

### replace

    public static final void replace(StringBuffer text,
                                     String search,
                                     String replace)

  Replaces all occurences of `search` in `text` by `replace` and returns the result.

  Parameters:
    `text` - text to work on
    `search` - replace this text by `replace`
    `replace` - replacement for `search`
  Returns:
    resulting string

### waitln

    public static final void waitln()

  Waits til a '\n' was read from System.in.

### deleteDir

    public static boolean deleteDir(File dir)

### getSpaces

    public static final StringBuffer getSpaces(int length)

  Get amount of spaces.

  Parameters:
    `length` - number of spaces
  Returns:
    String containig exactly `number` spaces

### getClassName

    public static final String getClassName(Class clazz)

  Get non qualified class name.

  Parameters:
    `clazz` -
  Returns:
    non qualified class name

### printAllSystemProperties

    public static final void printAllSystemProperties()

### getUserHomeDirectory

    public static final File getUserHomeDirectory()

### createRelativePath

    public static final String createRelativePath(File orgin,
                                                  File next)

  Create relative address from `orgin` to `next`.

  Parameters:
    `orgin` - this is the original location
    `next` - this should be the next location
  Returns:
    relative (or if neccessary absolute) file path

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Hilbert II - JAVA-Packages - Principia Mathematica II
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

©left GNU General Public Licence All Rights Reserved.