Package com.google.gwt.util.tools
Class Utility
java.lang.Object
com.google.gwt.util.tools.Utility
Deprecated, for removal: This API element is subject to removal in a future version.
In a future release this class will be package protected or removed.
A smattering of useful functions.
-
Constructor Summary
ConstructorsConstructorDescriptionUtility()Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclose(AutoCloseable closeable) Deprecated.Instead, use try-with-resources, or Guava'sCloseablesto close quietly.static FilecreateNormalFile(File parent, String fileName, boolean overwrite, boolean ignore) Deprecated.Consider usingFiles.createFile(Path, FileAttribute[])instead - if logging or errors are expected, consider inlining this method, as there is no exact replacement.static FilegetDirectory(File parent, String dirName, boolean create) Deprecated.Consider usingFiles.createDirectories(Path, FileAttribute[])instead - if logging or errors are expected, consider inlining this method, as there is no exact replacement.static FilegetDirectory(String dirPath, boolean create) Deprecated.Consider usingFiles.createDirectories(Path, FileAttribute[])instead - if logging or errors are expected, consider inlining this method, as there is no exact replacement.static StringgetFileFromClassPath(String partialPath) Deprecated.If writing a linker, useLinkerUtils.readClasspathFileAsString(String)instead.static StringDeprecated.There is no replacement for this method, many usages of GWT have no install path.static FilemakeTemporaryDirectory(File baseDir, String prefix) Deprecated.static voidstreamOut(InputStream in, OutputStream out, int bufferSize) Deprecated.useInputStream.transferTo(OutputStream)instead, letting it buffer internally.static intversionCompare(String v1, String v2) Deprecated.useSourceLevel.versionCompare(String, String)instead.static voidwriteTemplateBinaryFile(File file, byte[] contents) Deprecated.static voidDeprecated.There is no replacement for this, inline the method or use a template library of your choice.
-
Constructor Details
-
Utility
public Utility()Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Details
-
close
Deprecated.Instead, use try-with-resources, or Guava'sCloseablesto close quietly.Helper that ignores exceptions during close, because what are you going to do? -
createNormalFile
public static File createNormalFile(File parent, String fileName, boolean overwrite, boolean ignore) throws IOException Deprecated.Consider usingFiles.createFile(Path, FileAttribute[])instead - if logging or errors are expected, consider inlining this method, as there is no exact replacement.- Parameters:
parent- Parent directoryfileName- New file nameoverwrite- Is overwriting an existing file allowed?- Returns:
- Handle to the file
- Throws:
IOException- If the file cannot be created, or if the file already existed and overwrite was false.
-
getDirectory
Deprecated.Consider usingFiles.createDirectories(Path, FileAttribute[])instead - if logging or errors are expected, consider inlining this method, as there is no exact replacement.- 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
Filerepresenting a directory that now exists. - Throws:
IOException- If the directory is not found and/or cannot be created.
-
getDirectory
Deprecated.Consider usingFiles.createDirectories(Path, FileAttribute[])instead - if logging or errors are expected, consider inlining this method, as there is no exact replacement.- Parameters:
dirPath- Requested path for the directory.create- Create the directory if it does not already exist?- Returns:
- A
Filerepresenting a directory that now exists. - Throws:
IOException- If the directory is not found and/or cannot be created.
-
getFileFromClassPath
Deprecated.If writing a linker, useLinkerUtils.readClasspathFileAsString(String)instead.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 thisUtilityclass.- Parameters:
partialPath- the partial path to the resource on the class path- Returns:
- the contents of the file
- Throws:
IOException- if the file could not be found or an error occurred while reading it
-
getInstallPath
Deprecated.There is no replacement for this method, many usages of GWT have no install path. -
makeTemporaryDirectory
Deprecated.Creates a randomly-named temporary directory.- Parameters:
baseDir- base directory to contain the new directory. May benull, in which case the directory given by thejava.io.tmpdirsystem 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:
IOException
-
streamOut
Deprecated.useInputStream.transferTo(OutputStream)instead, letting it buffer internally.- Throws:
IOException
-
writeTemplateBinaryFile
Deprecated.- Throws:
IOException
-
writeTemplateFile
public static void writeTemplateFile(File file, String contents, Map<String, String> replacements) throws IOExceptionDeprecated.There is no replacement for this, inline the method or use a template library of your choice.- Throws:
IOException
-
versionCompare
Deprecated.useSourceLevel.versionCompare(String, String)instead.Handles comparison between version numbers (the right way(TM)). Examples of version strings: 1.6.7, 1.2_b10- Parameters:
v1- the first version to compare.v2- the second version to compare.- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
- Throws:
IllegalArgumentException- if the version number are not proper (i.e. the do not comply with the following regular expression [0-9]+(.[0-9]+)*(_[a-zA-Z0-9]+)?
-