Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| GWT 2.4.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.gwt.util.tools
Class Utility

    java.lang.Object
      com.google.gwt.util.tools.Utility

    public final class Utility

extends java.lang.Object

A smattering of useful functions.

Constructor Summary
`Utility()`

Method Summary
`static void` | `close(java.io.InputStream is)` Helper that ignores exceptions during close, because what are you going to do?
`static void` | `close(java.io.OutputStream os)` Helper that ignores exceptions during close, because what are you going to do?
`static void` | `close(java.io.RandomAccessFile f)` Helper that ignores exceptions during close, because what are you going to do?
`static void` | `close(java.io.Reader reader)` Helper that ignores exceptions during close, because what are you going to do?
`static void` | `close(java.net.Socket socket)` Helper that ignores exceptions during close, because what are you going to do?
`static void` | `close(java.io.Writer writer)` Helper that ignores exceptions during close, because what are you going to do?
`static java.io.File` | `createNormalFile(java.io.File parent, java.lang.String fileName, boolean overwrite, boolean ignore)`
`static java.io.File` | `getDirectory(java.io.File parent, java.lang.String dirName, boolean create)`
`static java.io.File` | `getDirectory(java.lang.String dirPath, boolean create)`
`static java.lang.String` | `getFileFromClassPath(java.lang.String partialPath)` Gets the contents of a file from the class path as a String.
`static java.lang.String` | `getInstallPath()`
`static java.io.File` | `makeTemporaryDirectory(java.io.File baseDir, java.lang.String prefix)` Creates a randomly-named temporary directory.
`static void` | `streamOut(java.io.File file, java.io.OutputStream out, int bufferSize)`
`static void` | `streamOut(java.io.InputStream in, java.io.OutputStream out, int bufferSize)`
`static void` | `writeTemplateBinaryFile(java.io.File file, byte[] contents)`
`static void` | `writeTemplateFile(java.io.File file, java.lang.String contents, java.util.Map<java.lang.String,java.lang.String> replacements)`

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

Constructor Detail

### Utility

    public Utility()

Method Detail

### close

    public static void close(java.io.InputStream is)

  Helper that ignores exceptions during close, because what are you going to do?

### close

    public static void close(java.io.OutputStream os)

  Helper that ignores exceptions during close, because what are you going to do?

### close

    public static void close(java.io.RandomAccessFile f)

  Helper that ignores exceptions during close, because what are you going to do?

### close

    public static void close(java.io.Reader reader)

  Helper that ignores exceptions during close, because what are you going to do?

### close

    public static void close(java.net.Socket socket)

  Helper that ignores exceptions during close, because what are you going to do?

### close

    public static void close(java.io.Writer writer)

  Helper that ignores exceptions during close, because what are you going to do?

### createNormalFile

    public static java.io.File createNormalFile(java.io.File parent,
                                                java.lang.String fileName,
                                                boolean overwrite,
                                                boolean ignore)
                                         throws java.io.IOException

  Parameters:
    `parent` - Parent directory
    `fileName` - New file name
    `overwrite` - Is overwriting an existing file allowed?
  Returns:
    Handle to the file
  Throws:
    `java.io.IOException` - If the file cannot be created, or if the file already existed and overwrite was false.

### getDirectory

    public static java.io.File getDirectory(java.io.File parent,
                                            java.lang.String dirName,
                                            boolean create)
                                     throws java.io.IOException

  Parameters:
    `parent` - Parent directory of the requested directory.
    `dirName` - Requested name for the directory.
    `create` - Create the directory if it does not already exist?
  Returns:
    A `File` representing a directory that now exists.
  Throws:
    `java.io.IOException` - If the directory is not found and/or cannot be created.

### getDirectory

    public static java.io.File getDirectory(java.lang.String dirPath,
                                            boolean create)
                                     throws java.io.IOException

  Parameters:
    `dirPath` - Requested path for the directory.
    `create` - Create the directory if it does not already exist?
  Returns:
    A `File` representing a directory that now exists.
  Throws:
    `java.io.IOException` - If the directory is not found and/or cannot be created.

### getFileFromClassPath

    public static java.lang.String getFileFromClassPath(java.lang.String partialPath)
                                                 throws java.io.IOException

  Gets the contents of a file from the class path as a String. Note: this method is only guaranteed to work for resources in the same class loader that contains this `Utility` class.

  Parameters:
    `partialPath` - the partial path to the resource on the class path
  Returns:
    the contents of the file
  Throws:
    `java.io.IOException` - if the file could not be found or an error occurred while reading it

### getInstallPath

    public static java.lang.String getInstallPath()

### makeTemporaryDirectory

    public static java.io.File makeTemporaryDirectory(java.io.File baseDir,
                                                      java.lang.String prefix)
                                               throws java.io.IOException

  Creates a randomly-named temporary directory.

  Parameters:
    `baseDir` - base directory to contain the new directory. May be `null`, in which case the directory given by the `java.io.tmpdir` system property will be used.
    `prefix` - the initial characters of the new directory name
  Returns:
    a newly-created temporary directory; the caller must delete this directory (either when done or on VM exit)
  Throws:
    `java.io.IOException`

### streamOut

    public static void streamOut(java.io.File file,
                                 java.io.OutputStream out,
                                 int bufferSize)
                          throws java.io.IOException

  Throws:
    `java.io.IOException`

### streamOut

    public static void streamOut(java.io.InputStream in,
                                 java.io.OutputStream out,
                                 int bufferSize)
                          throws java.io.IOException

  Throws:
    `java.io.IOException`

### writeTemplateBinaryFile

    public static void writeTemplateBinaryFile(java.io.File file,
                                               byte[] contents)
                                        throws java.io.IOException

  Throws:
    `java.io.IOException`

### writeTemplateFile

    public static void writeTemplateFile(java.io.File file,
                                         java.lang.String contents,
                                         java.util.Map<java.lang.String,java.lang.String> replacements)
                                  throws java.io.IOException

  Throws:
    `java.io.IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| GWT 2.4.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD