Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_ENCODING |
static File[] |
EMPTY_ARRAY_FILE |
static String[] |
EMPTY_ARRAY_STRING |
Modifier and Type | Method and Description |
---|---|
static byte[] |
append(byte[] xs,
byte x) |
static <T> T[] |
append(T[] xs,
T x) |
static <T> T[] |
append(T[] appendToThis,
T[] these) |
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 boolean |
copy(TreeLogger logger,
File in,
File out) |
static void |
copy(TreeLogger logger,
InputStream is,
File out)
Copies an input stream out to a file.
|
static void |
copy(TreeLogger logger,
InputStream is,
OutputStream os)
Copies an input stream out to an output stream.
|
static boolean |
copy(TreeLogger logger,
URL in,
File out) |
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 void |
deleteFilesInDirectory(File dir) |
static void |
deleteFilesStartingWith(File dir,
String prefix)
Deletes all files have the same base name as the specified file.
|
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 byte[][] |
getBytes(String[] s)
Returns an array of byte-arrays representing the default encoding for an
array of Strings.
|
static String |
getClassName(Class<?> cls) |
static String |
getClassName(String className) |
static String |
getFileFromInstallPath(String relativePath)
Gets the contents of a file.
|
static long |
getResourceModifiedTime(URL url)
Retrieves the last modified time of a provided URL.
|
static void |
hex4(char c,
StringBuffer sb)
Deprecated.
use
StringUtils.hex4(char, StringBuffer) instead. |
static void |
invokeInaccessableMethod(Class<?> targetClass,
String methodName,
Class<?>[] argumentTypes,
TypeOracle target,
Object[] arguments)
This method invokes an inaccessible method in another class.
|
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 String |
makeRelativePath(File from,
String to) |
static byte[] |
readFileAsBytes(File file) |
static char[] |
readFileAsChars(File file) |
static <T extends Serializable> |
readFileAsObject(File file,
Class<T> type) |
static String |
readFileAsString(File file) |
static String |
readNextLine(BufferedReader br)
Reads the next non-empty line.
|
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 SortedSet<String> |
recursiveListPartialPaths(File parent,
boolean includeDirs)
Recursively lists a directory, returning the partial paths of the child
files.
|
static void |
releaseThreadLocalBuf(byte[] buf)
Release a buffer previously returned from
takeThreadLocalBuf() . |
static File |
removeExtension(File file) |
static <T> T[] |
removeNulls(T[] a) |
static String |
slashify(String path) |
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 <T> T[] |
toArrayReversed(Class<? super T> componentType,
Collection<? extends T> coll)
Like
toArray(Class, Collection) , but the option of having the
array reversed. |
static String |
toHexString(byte[] bytes)
Deprecated.
use
StringUtils.toHexString(byte[]) instead. |
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 String[] |
toStringArray(Collection<String> coll)
Creates a string array from the contents of a collection.
|
static String[] |
toStrings(byte[][] bytes) |
static URL |
toURL(File f) |
static String |
toXml(Document doc) |
static byte[] |
toXmlUtf8(Document doc) |
static File |
tryCombine(File parentMaybeIgnored,
File childMaybeAbsolute) |
static File |
tryCombine(File parentMaybeIgnored,
String childMaybeAbsolute) |
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 |
writeCharsAsFile(TreeLogger logger,
File file,
char[] chars) |
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 |
writeStringToStream(OutputStream stream,
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 final File[] EMPTY_ARRAY_FILE
public static final String[] EMPTY_ARRAY_STRING
public static byte[] append(byte[] xs, byte x)
public static <T> T[] append(T[] xs, T x)
public static <T> T[] append(T[] appendToThis, T[] these)
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 boolean copy(TreeLogger logger, File in, File out) throws UnableToCompleteException
UnableToCompleteException
public static void copy(TreeLogger logger, InputStream is, File out) throws UnableToCompleteException
UnableToCompleteException
public static void copy(TreeLogger logger, InputStream is, OutputStream os) throws UnableToCompleteException
UnableToCompleteException
public static boolean copy(TreeLogger logger, URL in, File out) 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 void deleteFilesInDirectory(File dir)
public static void deleteFilesStartingWith(File dir, String prefix)
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 byte[][] getBytes(String[] s)
public static String getClassName(Class<?> cls)
cls
- A class whose name you want.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 long getResourceModifiedTime(URL url)
@Deprecated public static void hex4(char c, StringBuffer sb)
StringUtils.hex4(char, StringBuffer)
instead.public static void invokeInaccessableMethod(Class<?> targetClass, String methodName, Class<?>[] argumentTypes, TypeOracle target, Object[] arguments)
targetClass
- the class owning the methodmethodName
- the name of the methodargumentTypes
- the types of the parameters to the method calltarget
- the receiver of the method callarguments
- the parameters to the method callpublic 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 char[] readFileAsChars(File file)
public static <T extends Serializable> T readFileAsObject(File file, Class<T> type) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
public static String readNextLine(BufferedReader br)
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 SortedSet<String> recursiveListPartialPaths(File parent, boolean includeDirs)
parent
- the directory to start fromincludeDirs
- whether or not to include directories in the resultspublic static void releaseThreadLocalBuf(byte[] buf)
takeThreadLocalBuf()
.
The released buffer may then be reused.public static <T> T[] removeNulls(T[] a)
public static String slashify(String path)
path
- The path to slashify.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 <T> T[] toArrayReversed(Class<? super T> componentType, Collection<? extends T> coll)
toArray(Class, Collection)
, but the option of having the
array reversed.@Deprecated public static String toHexString(byte[] bytes)
StringUtils.toHexString(byte[])
instead.bytes
- byte array to convertpublic static String toString(byte[] bytes)
public static String[] toStringArray(Collection<String> coll)
public static String[] toStrings(byte[][] bytes)
public static byte[] toXmlUtf8(Document doc)
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 writeCharsAsFile(TreeLogger logger, File file, char[] chars) 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 writeStringToStream(OutputStream stream, String string) throws IOException
IOException
public static void writeUtf8(StringBuilder builder, OutputStream out) throws IOException
IOException
Copyright © 2018. All rights reserved.