Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_ENCODING |
Modifier and Type | Method and Description |
---|---|
static String |
computeStrongName(byte[] content)
Computes the MD5 hash for the specified byte array.
|
static String |
computeStrongName(byte[][] contents)
Computes the MD5 hash of the specified byte arrays.
|
static void |
copy(InputStream is,
OutputStream os) |
static void |
copy(TreeLogger logger,
InputStream is,
OutputStream os)
Copies an input stream out to an output stream.
|
static void |
copyNoClose(InputStream is,
OutputStream os)
Copies all of the bytes from the input stream to the output stream until
the input stream is EOF.
|
static Reader |
createReader(TreeLogger logger,
URL url) |
static boolean |
equalsNullCheck(Object thisObject,
Object thatObject)
Equality check through equals() that is also satisfied if both objects are null.
|
static String |
escapeXml(String unescaped)
Escapes '&', '<', '>', '"', and '\'' to their XML entity equivalents.
|
static void |
escapeXml(String code,
int start,
int end,
boolean quoteApostrophe,
StringBuilder builder)
Escapes '&', '<', '>', '"', and optionally ''' to their XML entity
equivalents.
|
static URL |
findSourceInClassPath(ClassLoader cl,
String sourceTypeName) |
static byte[] |
getBytes(String s)
Returns a byte-array representing the default encoding for a String.
|
static String |
getClassName(String className) |
static String |
getFileFromInstallPath(String relativePath)
Gets the contents of a file.
|
static String |
getPackageName(String qualifiedName) |
static long |
getResourceModifiedTime(URL url)
Retrieves the last modified time of a provided URL.
|
static boolean |
isValidJavaIdent(String token) |
static File |
makeRelativeFile(File from,
File to)
Attempts to make a path relative to a particular directory.
|
static String |
makeRelativePath(File from,
File to) |
static byte[] |
readFileAsBytes(File file) |
static <T extends Serializable> |
readFileAsObject(File file,
Class<T> type) |
static String |
readFileAsString(File file) |
static byte[] |
readStreamAsBytes(InputStream in)
Reads an entire input stream as bytes.
|
static <T> T |
readStreamAsObject(InputStream inputStream,
Class<T> type) |
static String |
readStreamAsString(InputStream in)
Reads an entire input stream as String.
|
static byte[] |
readURLAsBytes(URL url) |
static char[] |
readURLAsChars(URL url) |
static String |
readURLAsString(URL url) |
static byte[] |
readURLConnectionAsBytes(URLConnection connection) |
static void |
recursiveDelete(File file,
boolean childrenOnly)
Deletes a file or recursively deletes a directory.
|
static void |
recursiveDelete(File file,
boolean childrenOnly,
FileFilter filter)
Selectively deletes a file or recursively deletes a directory.
|
static void |
releaseThreadLocalBuf(byte[] buf)
Release a buffer previously returned from
takeThreadLocalBuf() . |
static String |
stripJarPathPrefix(String absolutePath)
Remove leading file:jar:...!/ prefix from source paths for source located in jars.
|
static byte[] |
takeThreadLocalBuf()
Get a large byte buffer local to this thread.
|
static <T> T[] |
toArray(Class<? super T> componentType,
Collection<? extends T> coll)
Creates an array from a collection of the specified component type and
size.
|
static String |
toString(byte[] bytes)
Returns a String representing the character content of the bytes; the bytes
must be encoded using the compiler's default encoding.
|
static File |
tryMakeCanonical(File file)
Attempts to find the canonical form of a file path.
|
static void |
writeBytesToFile(TreeLogger logger,
File where,
byte[] what) |
static void |
writeBytesToFile(TreeLogger logger,
File where,
byte[][] what)
Gathering write.
|
static void |
writeObjectAsFile(TreeLogger logger,
File file,
Object... objects)
Serializes an object and writes it to a file.
|
static void |
writeObjectToStream(OutputStream stream,
Object... objects)
Serializes an object and writes it to a stream.
|
static boolean |
writeStringAsFile(File file,
String string) |
static void |
writeStringAsFile(TreeLogger logger,
File file,
String string) |
static void |
writeUtf8(StringBuilder builder,
OutputStream out)
Writes the contents of a StringBuilder to an OutputStream, encoding
each character using the UTF-* encoding.
|
public static String DEFAULT_ENCODING
public static String computeStrongName(byte[] content)
public static String computeStrongName(byte[][] contents)
public static void copy(InputStream is, OutputStream os) throws IOException
IOException
public static void copy(TreeLogger logger, InputStream is, OutputStream os) throws UnableToCompleteException
UnableToCompleteException
public static void copyNoClose(InputStream is, OutputStream os) throws IOException
IOException
public static Reader createReader(TreeLogger logger, URL url) throws UnableToCompleteException
UnableToCompleteException
public static boolean equalsNullCheck(Object thisObject, Object thatObject)
public static String escapeXml(String unescaped)
public static void escapeXml(String code, int start, int end, boolean quoteApostrophe, StringBuilder builder)
code
- the input Stringstart
- the first character position to scan.end
- the character position following the last character to scan.quoteApostrophe
- if true, the ' character is quoted as
'builder
- a StringBuilder to be appended with the output.public static URL findSourceInClassPath(ClassLoader cl, String sourceTypeName)
public static byte[] getBytes(String s)
public static String getClassName(String className)
className
- A fully-qualified class name whose name you want.public static String getFileFromInstallPath(String relativePath)
relativePath
- relative path within the install directorypublic static String getPackageName(String qualifiedName)
qualifiedName
- A fully-qualified class name whose package name you want.public static long getResourceModifiedTime(URL url)
public static boolean isValidJavaIdent(String token)
public static File makeRelativeFile(File from, File to)
from
- the directory from which 'to' should be relativeto
- an absolute path which will be returned so that it is relative to
'from'public static byte[] readFileAsBytes(File file)
public static <T extends Serializable> T readFileAsObject(File file, Class<T> type) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
public static byte[] readStreamAsBytes(InputStream in)
public static <T> T readStreamAsObject(InputStream inputStream, Class<T> type) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
public static String readStreamAsString(InputStream in)
public static byte[] readURLAsBytes(URL url)
public static char[] readURLAsChars(URL url)
public static String readURLAsString(URL url)
public static byte[] readURLConnectionAsBytes(URLConnection connection)
public static void recursiveDelete(File file, boolean childrenOnly)
file
- the file to delete, or if this is a directory, the directory
that serves as the root of a recursive deletionchildrenOnly
- if true
, only the children of a
directory are recursively deleted but the specified directory
itself is spared; if false
, the specified
directory is also deleted; ignored if file
is not a
directorypublic static void recursiveDelete(File file, boolean childrenOnly, FileFilter filter)
file
- the file to delete, or if this is a directory, the directory
that serves as the root of a recursive deletionchildrenOnly
- if true
, only the children of a
directory are recursively deleted but the specified directory
itself is spared; if false
, the specified
directory is also deleted; ignored if file
is not a
directoryfilter
- only files matching this filter will be deletedpublic static void releaseThreadLocalBuf(byte[] buf)
takeThreadLocalBuf()
.
The released buffer may then be reused.public static String stripJarPathPrefix(String absolutePath)
absolutePath
- an absolute JAR file URL pathpublic static byte[] takeThreadLocalBuf()
releaseThreadLocalBuf(byte[])
on the returned buffer allows
subsequent callers to reuse the buffer later, avoiding unncessary
allocations and GC.public static <T> T[] toArray(Class<? super T> componentType, Collection<? extends T> coll)
public static String toString(byte[] bytes)
public static File tryMakeCanonical(File file)
public static void writeBytesToFile(TreeLogger logger, File where, byte[] what) throws UnableToCompleteException
UnableToCompleteException
public static void writeBytesToFile(TreeLogger logger, File where, byte[][] what) throws UnableToCompleteException
UnableToCompleteException
public static void writeObjectAsFile(TreeLogger logger, File file, Object... objects) throws UnableToCompleteException
UnableToCompleteException
public static void writeObjectToStream(OutputStream stream, Object... objects) throws IOException
IOException
public static void writeStringAsFile(TreeLogger logger, File file, String string) throws UnableToCompleteException
UnableToCompleteException
public static void writeUtf8(StringBuilder builder, OutputStream out) throws IOException
IOException
Copyright © 2018. All rights reserved.