Class UtilPlume
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Deprecated.static class
Deprecated.static final class
Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
abbreviateNumber
(long val) Deprecated.static @Nullable String
appendProperty
(Properties p, String key, String value) Set the property to its previous value concatenated to the given value.static String
Execute the given command, and return all its output as a string.static String
Execute the given command, and return all its output as a string.static String
Deprecated.static BufferedOutputStream
bufferedFileOutputStream
(String filename, boolean append) static BufferedReader
bufferedFileReader
(File file) Deprecated.static BufferedReader
bufferedFileReader
(File file, @Nullable String charsetName) Deprecated.static BufferedReader
bufferedFileReader
(String filename) Deprecated.static BufferedReader
bufferedFileReader
(String filename, @Nullable String charsetName) Deprecated.static BufferedWriter
bufferedFileWriter
(String filename) Deprecated.static BufferedWriter
bufferedFileWriter
(String filename, boolean append) Deprecated.static boolean
canCreateAndWrite
(File file) Deprecated.static <T> @PolyNull @PolySigned T
clone
(@PolyNull @PolySigned T data) Clones the given object by callingclone()
reflectively.static int
Deprecated.static int
Deprecated.static int
Deprecated.static long
countLines
(String filename) Deprecated.static File
createTempDir
(String prefix, String suffix) Deprecated.static boolean
Deprecated.static boolean
Deprecated.static boolean
equalFiles
(String file1, String file2) Deprecated.static boolean
equalFiles
(String file1, String file2, boolean trimLines) Deprecated.static String
escapeJava
(char c) Deprecated.static String
escapeJava
(Character ch) Deprecated.static String
escapeJava
(String orig) Deprecated.static String
escapeNonASCII
(String orig) Deprecated.static String
Deprecated.static String
escapeNonJava
(String orig) Deprecated.static File
expandFilename
(File name) Deprecated.static String
expandFilename
(String name) Deprecated.static InputStream
fileInputStream
(File file) Deprecated.static InputStream
fileInputStream
(Path path) Deprecated.Deprecated.static InputStreamReader
fileReader
(File file) Deprecated.static InputStreamReader
fileReader
(File file, @Nullable String charsetName) Deprecated.static InputStreamReader
fileReader
(String filename) Deprecated.static InputStreamReader
fileReader
(Path path) Deprecated.static InputStreamReader
fileReader
(Path path, @Nullable String charsetName) Deprecated.static <T> T
firstNonNull
(T first, T second) Return the first argument if it is non-null, otherwise return the second argument.static void
gc()
Deprecated.useSystemPlume.gc()
static boolean
getBooleanProperty
(Properties p, String key) Determines whether a property has a string value that represents true: "true", "yes", or "1".static boolean
getBooleanProperty
(Properties p, String key, boolean defaultValue) Determines whether a property has a string value that represents true: "true", "yes", or "1".static int
hash
(double x) Deprecated.static int
hash
(double @Nullable [] a) Deprecated.static int
hash
(double @Nullable [] a, double @Nullable [] b) Returns a hash of the arguments.static int
hash
(double a, double b) Deprecated.static int
hash
(double a, double b, double c) Deprecated.static int
hash
(long l) Deprecated.useLong.hashCode()
static int
hash
(long @Nullable [] a) Deprecated.static int
hash
(long @Nullable [] a, long @Nullable [] b) Returns a hash of the arguments.static int
hash
(long a, long b) Deprecated.static int
hash
(long a, long b, long c) Deprecated.static int
Deprecated.static int
Deprecated.static int
Deprecated.static int
Deprecated.static String
indentLines
(@org.checkerframework.checker.index.qual.NonNegative int indent, @Nullable Object o) Deprecated.static String
indentLinesExceptFirst
(@org.checkerframework.checker.index.qual.NonNegative int indent, @Nullable Object o) Deprecated.static String
inferLineSeparator
(File file) Deprecated.static String
inferLineSeparator
(String filename) Deprecated.static int
Deprecated.use CollectionsPlume.intersectionCardinalitystatic int
intersectionCardinality
(BitSet a, BitSet b, BitSet c) Deprecated.use CollectionsPlume.intersectionCardinalitystatic boolean
intersectionCardinalityAtLeast
(BitSet a, BitSet b, @org.checkerframework.checker.index.qual.NonNegative int i) Deprecated.use CollectionsPlume.intersectionCardinalityAtLeaststatic boolean
intersectionCardinalityAtLeast
(BitSet a, BitSet b, BitSet c, @org.checkerframework.checker.index.qual.NonNegative int i) Deprecated.use CollectionsPlume.intersectionCardinalityAtLeaststatic String
javaSource
(File name) Deprecated.static <T> String
join
(@Signed T[] a, CharSequence delim) Deprecated.usejoin(CharSequence, Object...)
which has the arguments in the other orderstatic <T> String
join
(CharSequence delim, @Signed T... a) Deprecated.static String
join
(CharSequence delim, Iterable<? extends @Signed @PolyNull Object> v) Deprecated.static String
join
(Iterable<? extends @Signed @PolyNull Object> v, CharSequence delim) Deprecated.usejoin(CharSequence, Iterable)
which has the arguments in the other orderstatic <T> String
joinLines
(@Signed T... a) Deprecated.static String
Deprecated.static LineNumberReader
lineNumberFileReader
(File file) Deprecated.static LineNumberReader
lineNumberFileReader
(String filename) Deprecated.static String
Deprecated.static String
mapToStringAndClass
(Map<? extends @Signed @PolyNull Object, ? extends @Signed @PolyNull Object> m) static String
Deprecated.static String
prefixLines
(String prefix, @Nullable Object o) Deprecated.static String
prefixLinesExceptFirst
(String prefix, @Nullable Object o) static boolean
propertyIsTrue
(Properties p, String key) static String
Deprecated.static String
Deprecated.static Object
readObject
(File file) Deprecated.static String
removeWhitespaceAfter
(String arg, String delimiter) static String
removeWhitespaceAround
(String arg, String delimiter) static String
removeWhitespaceBefore
(String arg, String delimiter) static String
replacePrefix
(String target, String oldStr, String newStr) static String
replaceString
(String target, String oldStr, String newStr) Deprecated.static String
replaceSuffix
(String target, String oldStr, String newStr) static String
rpad
(double num, @org.checkerframework.checker.index.qual.NonNegative int length) Deprecated.static String
rpad
(int num, @org.checkerframework.checker.index.qual.NonNegative int length) Deprecated.static String
Deprecated.static @Nullable String
setDefaultMaybe
(Properties p, String key, String value) Set the property only if it was not previously set.static void
sleep
(long millis) Deprecated.static String[]
Deprecated.static String[]
Deprecated.static String[]
splitLines
(String s) Deprecated.static String
Returns a String representation of the stack trace (the backtrace) of the given Throwable.static void
streamCopy
(InputStream from, OutputStream to) Deprecated.streamLines
(InputStream stream) Deprecated.static String
Deprecated.Deprecated.Deprecated.Deprecated.static String
toStringAndClass
(@Nullable Object o) Deprecated.static String
unescapeJava
(String orig) Deprecated.static String
unescapeNonJava
(String orig) Deprecated.static long
Deprecated.static long
usedMemory
(boolean forceGc) Deprecated.static void
Deprecated.static void
writeObject
(Object o, File file) Deprecated.
-
Method Details
-
clone
public static <T> @PolyNull @PolySigned T clone(@PolyNull @PolySigned T data) Clones the given object by callingclone()
reflectively. It is not possible to callObject.clone()
directly because it has protected visibility.- Type Parameters:
T
- the type of the object to clone- Parameters:
data
- the object to clone- Returns:
- a clone of the object
-
firstNonNull
public static <T> T firstNonNull(T first, T second) Return the first argument if it is non-null, otherwise return the second argument. Throws an exception if both arguments are null.- Type Parameters:
T
- the type of the arguments- Parameters:
first
- a referencesecond
- a reference- Returns:
- the first argument that is non-null
-
intersectionCardinalityAtLeast
@Deprecated @Pure public static boolean intersectionCardinalityAtLeast(BitSet a, BitSet b, @org.checkerframework.checker.index.qual.NonNegative int i) Deprecated.use CollectionsPlume.intersectionCardinalityAtLeastReturns true if the cardinality of the intersection of the two BitSets is at least the given value.- Parameters:
a
- the first BitSet to intersectb
- the second BitSet to intersecti
- the cardinality bound- Returns:
- true iff size(a intersect b) ≥ i
-
intersectionCardinalityAtLeast
@Deprecated @Pure public static boolean intersectionCardinalityAtLeast(BitSet a, BitSet b, BitSet c, @org.checkerframework.checker.index.qual.NonNegative int i) Deprecated.use CollectionsPlume.intersectionCardinalityAtLeastReturns true if the cardinality of the intersection of the three BitSets is at least the given value.- Parameters:
a
- the first BitSet to intersectb
- the second BitSet to intersectc
- the third BitSet to intersecti
- the cardinality bound- Returns:
- true iff size(a intersect b intersect c) ≥ i
-
intersectionCardinality
Deprecated.use CollectionsPlume.intersectionCardinalityReturns the cardinality of the intersection of the two BitSets.- Parameters:
a
- the first BitSet to intersectb
- the second BitSet to intersect- Returns:
- size(a intersect b)
-
intersectionCardinality
Deprecated.use CollectionsPlume.intersectionCardinalityReturns the cardinality of the intersection of the three BitSets.- Parameters:
a
- the first BitSet to intersectb
- the second BitSet to intersectc
- the third BitSet to intersect- Returns:
- size(a intersect b intersect c)
-
fileInputStream
Deprecated.Returns an InputStream for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
path
- the possibly-compressed file to read- Returns:
- an InputStream for file
- Throws:
IOException
- if there is trouble reading the file
-
fileInputStream
Deprecated.Returns an InputStream for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
file
- the possibly-compressed file to read- Returns:
- an InputStream for file
- Throws:
IOException
- if there is trouble reading the file
-
fileReader
@Deprecated public static InputStreamReader fileReader(String filename) throws FileNotFoundException, IOException Deprecated.Returns a Reader for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
filename
- the possibly-compressed file to read- Returns:
- an InputStream for filename
- Throws:
IOException
- if there is trouble reading the fileFileNotFoundException
- if the file is not found
-
fileReader
@Deprecated public static InputStreamReader fileReader(Path path) throws FileNotFoundException, IOException Deprecated.Returns a Reader for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
path
- the possibly-compressed file to read- Returns:
- an InputStreamReader for file
- Throws:
FileNotFoundException
- if the file cannot be foundIOException
- if there is trouble reading the file
-
fileReader
@Deprecated public static InputStreamReader fileReader(Path path, @Nullable String charsetName) throws FileNotFoundException, IOException Deprecated.Returns a Reader for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
path
- the possibly-compressed file to readcharsetName
- null, or the name of a Charset to use when reading the file- Returns:
- an InputStreamReader for file
- Throws:
FileNotFoundException
- if the file cannot be foundIOException
- if there is trouble reading the file
-
fileReader
@Deprecated public static InputStreamReader fileReader(File file) throws FileNotFoundException, IOException Deprecated.Returns a Reader for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
file
- the possibly-compressed file to read- Returns:
- an InputStreamReader for file
- Throws:
FileNotFoundException
- if the file cannot be foundIOException
- if there is trouble reading the file
-
fileReader
@Deprecated public static InputStreamReader fileReader(File file, @Nullable String charsetName) throws FileNotFoundException, IOException Deprecated.Returns a Reader for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
file
- the possibly-compressed file to readcharsetName
- null, or the name of a Charset to use when reading the file- Returns:
- an InputStreamReader for file
- Throws:
FileNotFoundException
- if the file cannot be foundIOException
- if there is trouble reading the file
-
bufferedFileReader
@Deprecated public static BufferedReader bufferedFileReader(String filename) throws FileNotFoundException, IOException Deprecated.Returns a BufferedReader for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
filename
- the possibly-compressed file to read- Returns:
- a BufferedReader for file
- Throws:
FileNotFoundException
- if the file cannot be foundIOException
- if there is trouble reading the file
-
bufferedFileReader
@Deprecated public static BufferedReader bufferedFileReader(File file) throws FileNotFoundException, IOException Deprecated.Returns a BufferedReader for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
file
- the possibility-compressed file to read- Returns:
- a BufferedReader for file
- Throws:
FileNotFoundException
- if the file cannot be foundIOException
- if there is trouble reading the file
-
bufferedFileReader
@Deprecated public static BufferedReader bufferedFileReader(String filename, @Nullable String charsetName) throws FileNotFoundException, IOException Deprecated.Returns a BufferedReader for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
filename
- the possibly-compressed file to readcharsetName
- the character set to use when reading the file- Returns:
- a BufferedReader for filename
- Throws:
FileNotFoundException
- if the file cannot be foundIOException
- if there is trouble reading the file
-
bufferedFileReader
@Deprecated public static BufferedReader bufferedFileReader(File file, @Nullable String charsetName) throws FileNotFoundException, IOException Deprecated.Returns a BufferedReader for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
file
- the possibly-compressed file to readcharsetName
- the character set to use when reading the file- Returns:
- a BufferedReader for file
- Throws:
FileNotFoundException
- if the file cannot be foundIOException
- if there is trouble reading the file
-
lineNumberFileReader
@Deprecated public static LineNumberReader lineNumberFileReader(String filename) throws FileNotFoundException, IOException Deprecated.Returns a LineNumberReader for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
filename
- the possibly-compressed file to read- Returns:
- a LineNumberReader for filename
- Throws:
FileNotFoundException
- if the file cannot be foundIOException
- if there is trouble reading the file
-
lineNumberFileReader
@Deprecated public static LineNumberReader lineNumberFileReader(File file) throws FileNotFoundException, IOException Deprecated.Returns a LineNumberReader for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
file
- the possibly-compressed file to read- Returns:
- a LineNumberReader for file
- Throws:
FileNotFoundException
- if the file cannot be foundIOException
- if there is trouble reading the file
-
bufferedFileWriter
Deprecated.Returns a BufferedWriter for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
filename
- the possibly-compressed file to write- Returns:
- a BufferedWriter for filename
- Throws:
IOException
- if there is trouble writing the file
-
bufferedFileWriter
@Deprecated public static BufferedWriter bufferedFileWriter(String filename, boolean append) throws IOException Deprecated.Returns a BufferedWriter for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
filename
- the possibly-compressed file to writeappend
- if true, the resulting BufferedWriter appends to the end of the file instead of the beginning- Returns:
- a BufferedWriter for filename
- Throws:
IOException
- if there is trouble writing the file
-
bufferedFileOutputStream
@Deprecated public static BufferedOutputStream bufferedFileOutputStream(String filename, boolean append) throws IOException Returns a BufferedOutputStream for the file, accounting for the possibility that the file is compressed. (A file whose name ends with ".gz" is treated as compressed.)Warning: The "gzip" program writes and reads files containing concatenated gzip files. As of Java 1.4, Java reads just the first one: it silently discards all characters (including gzipped files) after the first gzipped file.
- Parameters:
filename
- the possibly-compressed file to writeappend
- if true, the resulting BufferedOutputStream appends to the end of the file instead of the beginning- Returns:
- a BufferedOutputStream for filename
- Throws:
IOException
- if there is trouble writing the file
-
countLines
Deprecated.Count the number of lines in the specified file.- Parameters:
filename
- file whose size to count- Returns:
- number of lines in filename
- Throws:
IOException
- if there is trouble reading the file
-
fileLines
Deprecated.Returns the contents of the file, as a list of strings, one per line. The lines do not include any line termination characters.- Parameters:
filename
- the file whose contents to return- Returns:
- the contents of
filename
, one string per line - Throws:
IOException
- if there was a problem reading the file
-
inferLineSeparator
Deprecated.Tries to infer the line separator used in a file.- Parameters:
filename
- the file to infer a line separator from- Returns:
- the inferred line separator used in filename
- Throws:
IOException
- if there is trouble reading the file
-
inferLineSeparator
Deprecated.Tries to infer the line separator used in a file.- Parameters:
file
- the file to infer a line separator from- Returns:
- the inferred line separator used in filename
- Throws:
IOException
- if there is trouble reading the file
-
equalFiles
Deprecated.Returns true iff files have the same contents.- Parameters:
file1
- first file to comparefile2
- second file to compare- Returns:
- true iff the files have the same contents
-
equalFiles
Deprecated.Returns true iff the files have the same contents.- Parameters:
file1
- first file to comparefile2
- second file to comparetrimLines
- if true, call String.trim on each line before comparing- Returns:
- true iff the files have the same contents
-
canCreateAndWrite
Deprecated.Returns true if the file exists and is writable, or if the file can be created.- Parameters:
file
- the file to create and write- Returns:
- true iff the file can be created and written
-
createTempDir
Deprecated.Creates an empty directory in the default temporary-file directory, using the given prefix and suffix to generate its name. For example, calling createTempDir("myPrefix", "mySuffix") will create the following directory: temporaryFileDirectory/myUserName/myPrefix_someString_suffix. someString is internally generated to ensure no temporary files of the same name are generated.- Parameters:
prefix
- the prefix string to be used in generating the file's name; must be at least three characters longsuffix
- the suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used Returns: An abstract pathname denoting a newly-created empty file- Returns:
- a File representing the newly-created temporary directory
- Throws:
IllegalArgumentException
- If the prefix argument contains fewer than three charactersIOException
- If a file could not be createdSecurityException
- If a security manager exists and its SecurityManager.checkWrite(java.lang.String) method does not allow a file to be created- See Also:
-
deleteDir
Deprecated.Deletes the directory at dirName and all its files. Also works on regular files.- Parameters:
dirName
- the directory to delete- Returns:
- true if and only if the file or directory is successfully deleted; false otherwise
-
deleteDir
Deprecated.Deletes the directory at dir and all its files. Also works on regular files.- Parameters:
dir
- the directory to delete- Returns:
- true if and only if the file or directory is successfully deleted; false otherwise
-
expandFilename
Deprecated.Does tilde expansion on a file name (to the user's home directory).- Parameters:
name
- file whose name to expand- Returns:
- file with expanded file
-
expandFilename
Deprecated.Does tilde expansion on a file name (to the user's home directory).- Parameters:
name
- filename to expand- Returns:
- expanded filename
-
javaSource
Deprecated.Returns a string version of the filename that can be used in Java source. On Windows, the file will return a backslash separated string. Since backslash is an escape character, it must be quoted itself inside the string.The current implementation presumes that backslashes don't appear in filenames except as windows path separators. That seems like a reasonable assumption.
- Parameters:
name
- file whose name to quote- Returns:
- a string version of the name that can be used in Java source
-
writeObject
Deprecated.Writes an Object to a File.- Parameters:
o
- the object to writefile
- the file to which to write the object- Throws:
IOException
- if there is trouble writing the file
-
readObject
Deprecated.Reads an Object from a File. This is a wrapper aroundObjectInputStream.readObject()
, but it takes aFile
as an argument. Note that use of that method can lead to security vulnerabilities.- Parameters:
file
- the file from which to read- Returns:
- the object read from the file
- Throws:
IOException
- if there is trouble reading the fileClassNotFoundException
- if the object's class cannot be found
-
readerContents
Deprecated.Reads the entire contents of the reader and returns it as a string. Any IOException encountered will be turned into an Error.- Parameters:
r
- the Reader to read- Returns:
- the entire contents of the reader, as a string
-
readFile
Deprecated.Reads the entire contents of the file and returns it as a string. Any IOException encountered will be turned into an Error.You could use
new String(Files.readAllBytes(...))
, but it requires a Path rather than a File, and it can throw IOException which has to be caught.- Parameters:
file
- the file to read- Returns:
- the entire contents of the reader, as a string
-
writeFile
Deprecated.Creates a file with the given name and writes the specified string to it. If the file currently exists (and is writable) it is overwritten Any IOException encountered will be turned into an Error.- Parameters:
file
- the file to write tocontents
- the text to put in the file
-
hash
public static int hash(double @Nullable [] a, double @Nullable [] b) Returns a hash of the arguments.- Parameters:
a
- value to be hashedb
- value to be hashed- Returns:
- a hash of the arguments
-
hash
public static int hash(long @Nullable [] a, long @Nullable [] b) Returns a hash of the arguments.- Parameters:
a
- value to be hashedb
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.Returns a hash of the arguments. Note that this differs from the result ofDouble.hashCode()
.- Parameters:
x
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.Returns a hash of the arguments.- Parameters:
a
- value to be hashedb
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.Returns a hash of the arguments.- Parameters:
a
- value to be hashedb
- value to be hashedc
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.Returns a hash of the arguments.- Parameters:
a
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.useLong.hashCode()
Returns a hash of the arguments. Note that this differs from the result ofLong.hashCode()
. A problem withLong.hashCode()
is that it maps -1 and 0 to the same value, 0.- Parameters:
l
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.Returns a hash of the arguments.- Parameters:
a
- value to be hashedb
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.Returns a hash of the arguments.- Parameters:
a
- value to be hashedb
- value to be hashedc
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.Returns a hash of the arguments.- Parameters:
a
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.Returns a hash of the arguments.- Parameters:
a
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.Returns a hash of the arguments.- Parameters:
a
- value to be hashedb
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.Returns a hash of the arguments.- Parameters:
a
- value to be hashedb
- value to be hashedc
- value to be hashed- Returns:
- a hash of the arguments
-
hash
Deprecated.Returns a hash of the arguments.- Parameters:
a
- value to be hashed- Returns:
- a hash of the arguments
-
mapToStringAndClass
@Deprecated public static String mapToStringAndClass(Map<? extends @Signed @PolyNull Object, ? extends @Signed @PolyNull Object> m) Deprecated.Convert a map to a string, printing the runtime class of keys and values.- Parameters:
m
- a map- Returns:
- a string representation of the map
-
toStringAndClass
Deprecated.Returns a string representation of a value and its run-time class.- Parameters:
o
- an object- Returns:
- a string representation of the value and its run-time class
-
backticks
Execute the given command, and return all its output as a string.- Parameters:
command
- a command to execute on the command line- Returns:
- all the output of the command
-
backticks
Execute the given command, and return all its output as a string.- Parameters:
command
- a command to execute on the command line, as a list of strings (the command, then its arguments)- Returns:
- all the output of the command
-
propertyIsTrue
Determines whether a property has value "true", "yes", or "1".- Parameters:
p
- a Properties object in which to look up the propertykey
- name of the property to look up- Returns:
- true iff the property has value "true", "yes", or "1"
- See Also:
-
getBooleanProperty
Determines whether a property has a string value that represents true: "true", "yes", or "1". Errs if the property is set to a value that is not one of "true", "false", "yes", "no", "1", or "0".- Parameters:
p
- a Properties object in which to look up the propertykey
- name of the property to look updefaultValue
- the value to return if the property is not set- Returns:
- true iff the property has value "true", "yes", or "1"
- See Also:
-
getBooleanProperty
Determines whether a property has a string value that represents true: "true", "yes", or "1". Errs if the property is set to a value that is not one of "true", "false", "yes", "no", "1", or "0".- Parameters:
p
- a Properties object in which to look up the propertykey
- name of the property to look up- Returns:
- true iff the property has value "true", "yes", or "1"
- See Also:
-
appendProperty
Set the property to its previous value concatenated to the given value. Return the previous value.- Parameters:
p
- a Properties object in which to look up the propertykey
- name of the property to look upvalue
- value to concatenate to the previous value of the property- Returns:
- the previous value of the property
- See Also:
-
setDefaultMaybe
Set the property only if it was not previously set.- Parameters:
p
- a Properties object in which to look up the propertykey
- name of the property to look upvalue
- value to set the property to, if it is not already set- Returns:
- the previous value of the property
- See Also:
-
streamCopy
Deprecated.Copy the contents of the input stream to the output stream.- Parameters:
from
- input streamto
- output stream
-
streamString
Deprecated.Returns a String containing all the characters from the input stream.- Parameters:
is
- input stream to read- Returns:
- a String containing all the characters from the input stream
-
streamLines
Deprecated.Reads all lines from the stream and returns them in aList<String>
.- Parameters:
stream
- the stream to read from- Returns:
- the list of lines read from the stream
- Throws:
IOException
- if there is an error reading from the stream
-
replaceString
Deprecated.Returns a new string which is the text of target with all instances of oldStr replaced by newStr.- Parameters:
target
- the string to do replacement inoldStr
- the substring to replacenewStr
- the replacement- Returns:
- target with all instances of oldStr replaced by newStr
-
replacePrefix
Returns the target with an occurrence of oldStr at the start replaced by newStr. Returns the target if it does not strt with oldStr.An alternative to this is to use regular expressions:
target.replaceFirst("^" + Pattern.quote(oldStr), newStr)
- Parameters:
target
- the string to do replacement inoldStr
- the prefix to replacenewStr
- the replacement- Returns:
- the target with an occurrence of oldStr at the start replaced by newStr; returns the target if it does not start with oldStr
-
replaceSuffix
Returns the target with an occurrence of oldStr at the end replaced by newStr. Returns the target if it does not end with oldStr.An alternative to this is to use regular expressions:
target.replaceLast(Pattern.quote(oldStr) + "$", newStr)
- Parameters:
target
- the string to do replacement inoldStr
- the substring to replacenewStr
- the replacement- Returns:
- the target with an occurrence of oldStr at the start replaced by newStr; returns the target if it does not start with oldStr
-
prefixLines
Deprecated.Returns the printed represenation of a value, with each line prefixed by another string.- Parameters:
prefix
- the prefix to place before each lineo
- the value to be printed- Returns:
- the printed representation of
o
, with each line prefixed by the given prefix
-
prefixLinesExceptFirst
Returns the printed represenation of a value, with each line (except the first) prefixed by another string.- Parameters:
prefix
- the prefix to place before each lineo
- the value to be printed- Returns:
- the printed representation of
o
, with each line (except the first) prefixed by the given prefix
-
indentLines
@Deprecated public static String indentLines(@org.checkerframework.checker.index.qual.NonNegative int indent, @Nullable Object o) Deprecated.Returns the printed representation of a value, with each line indented byindent
spaces.- Parameters:
indent
- the number of spaces to indento
- the value whose printed representation string to increase indentation of- Returns:
- the printed representation of
o
, with each line prefixed byindent
space characters
-
indentLinesExceptFirst
@Deprecated public static String indentLinesExceptFirst(@org.checkerframework.checker.index.qual.NonNegative int indent, @Nullable Object o) Deprecated.Returns the printed representation of a value, with each line (except the first) indented byindent
spaces.- Parameters:
indent
- the number of spaces to indento
- the value whose printed representation string to increase indentation of- Returns:
- the printed representation of
o
, with each line (except the first) prefixed byindent
space characters
-
split
Deprecated.Returns an array of Strings representing the characters between successive instances of the delimiter character. Always returns an array of length at least 1 (it might contain only the empty string).Consider using the built-in String.split method, which takes a regular expression whereas this method takes a a character that is interpreted literally.
- Parameters:
s
- the string to splitdelim
- delimiter to split the string on- Returns:
- array of length at least 1, containing s split on delimiter
- See Also:
-
split
Deprecated.Returns an array of Strings representing the characters between successive instances of the delimiter String. Always returns an array of length at least 1 (it might contain only the empty string).Consider using the built-in String.split method, method, which takes a regular expression whereas this method takes string.
- Parameters:
s
- the string to splitdelim
- delimiter to split the string on- Returns:
- array of length at least 1, containing s split on delimiter
- See Also:
-
splitLines
Deprecated.Returns an array of Strings, one for each line in the argument. Always returns an array of length at least 1 (it might contain only the empty string). All common line separators (cr, lf, cr-lf, or lf-cr) are supported. Note that a string that ends with a line separator will return an empty string as the last element of the array.- Parameters:
s
- the string to split- Returns:
- an array of Strings, one for each line in the argument
- See Also:
-
join
Deprecated.usejoin(CharSequence, Object...)
which has the arguments in the other orderConcatenate the string representations of the array elements, placing the delimiter between them.This differs from the built-in
String.join()
method added in Java 8, in that this takes an array of Objects but that method takes an array of CharSequences. Use the Java 8String.join()
method when the arguments are CharSequences.- Type Parameters:
T
- the type of array elements- Parameters:
a
- array of values to concatenatedelim
- delimiter to place between printed representations- Returns:
- the concatenation of the string representations of the values, with the delimiter between
-
join
Deprecated.Concatenate the string representations of the array elements, placing the delimiter between them.This differs from the built-in
String.join()
method added in Java 8, in that this takes any arbitrary array but that method takes an array of CharSequences. Use the String method when the arguments are CharSequences.- Type Parameters:
T
- the type of array elements- Parameters:
a
- array of values to concatenatedelim
- delimiter to place between printed representations- Returns:
- the concatenation of the string representations of the values, with the delimiter between
-
joinLines
Deprecated.Concatenate the string representations of the objects, placing the system-specific line separator between them.- Type Parameters:
T
- the type of array elements- Parameters:
a
- array of values to whose string representation to concatenate- Returns:
- the concatenation of the string representations of the values, each on its own line
-
join
@Deprecated public static String join(Iterable<? extends @Signed @PolyNull Object> v, CharSequence delim) Deprecated.usejoin(CharSequence, Iterable)
which has the arguments in the other orderConcatenate the string representations of the objects, placing the delimiter between them.This differs from the
String.join()
method added in Java 8, in that this takes any array but that method takes an array of CharSequences.- Parameters:
v
- collection of values to concatenatedelim
- delimiter to place between printed representations- Returns:
- the concatenation of the string representations of the values, with the delimiter between
- See Also:
-
join
@Deprecated public static String join(CharSequence delim, Iterable<? extends @Signed @PolyNull Object> v) Deprecated.Concatenate the string representations of the objects, placing the delimiter between them.This differs from the
String.join()
method added in Java 8, in that this takes any Iterable but that method takes onlyIterable<? extends CharSequence>
.- Parameters:
v
- collection of values to concatenatedelim
- delimiter to place between printed representations- Returns:
- the concatenation of the string representations of the values, with the delimiter between
- See Also:
-
joinLines
Deprecated.Concatenate the string representations of the objects, placing the system-specific line separator between them.- Parameters:
v
- list of values to concatenate- Returns:
- the concatenation of the string representations of the values, each on its own line
- See Also:
-
escapeNonJava
Deprecated.- Parameters:
orig
- string to quote- Returns:
- quoted version of orig
-
escapeJava
Deprecated.Escapes a String so that it is expressible in Java source code. By surrounding the return value with double quote marks, the result will be a Java string literal denoting the original string.Returns a new string only if any modifications were necessary.
Compared to the `escapeJava` method in Apache Commons Text StringEscapeUtils, this one correctly handles non-printable ASCII characters.
- Parameters:
orig
- string to quote- Returns:
- quoted version of orig
-
escapeNonJava
Deprecated.- Parameters:
ch
- character to quote- Returns:
- quoted version of ch
-
escapeJava
Deprecated.LikeescapeJava(String)
, but for a single character.- Parameters:
ch
- character to quote- Returns:
- quoted version of ch
-
escapeJava
Deprecated.LikeescapeJava(String)
, but for a single character.- Parameters:
c
- character to quote- Returns:
- quoted version of ch
-
escapeNonASCII
Deprecated.Escape unprintable characters in the target, following the usual Java backslash conventions, so that the result is sure to be printable ASCII. Returns a new string.- Parameters:
orig
- string to quote- Returns:
- quoted version of orig
-
unescapeNonJava
Deprecated.Convert a string from Java source code format (with escape sequences) into the string it would represent at run time. This is the inverse operation ofescapeJava(java.lang.String)
, but it is not a general unescaping mechanism for Java strings.Compared to the `unescapeJava` method in Apache Commons Text StringEscapeUtils, this one correctly handles non-printable ASCII characters.
- Parameters:
orig
- string to quote- Returns:
- quoted version of orig
-
unescapeJava
Deprecated.Convert a string from Java source code format (with escape sequences) into the string it would represent at run time. This is the inverse operation ofescapeJava(java.lang.String)
, but it is not a general unescaping mechanism for Java strings.Compared to the `unescapeJava` method in Apache Commons Text StringEscapeUtils, this one correctly handles non-printable ASCII characters.
- Parameters:
orig
- string to quote- Returns:
- quoted version of orig
-
removeWhitespaceAround
Remove all whitespace before or after instances of delimiter.- Parameters:
arg
- string to remove whitespace indelimiter
- string to remove whitespace abutting- Returns:
- version of arg, with whitespace abutting delimiter removed
-
removeWhitespaceAfter
Remove all whitespace after instances of delimiter.- Parameters:
arg
- string to remove whitespace indelimiter
- string to remove whitespace after- Returns:
- version of arg, with whitespace after delimiter removed
-
removeWhitespaceBefore
Remove all whitespace before instances of delimiter.- Parameters:
arg
- string to remove whitespace indelimiter
- string to remove whitespace before- Returns:
- version of arg, with whitespace before delimiter removed
-
nplural
Deprecated.Returns either "n noun" or "n nouns" depending on n. Adds "es" to words ending with "ch", "s", "sh", or "x".- Parameters:
n
- count of nounsnoun
- word being counted- Returns:
- noun, if n==1; otherwise, pluralization of noun
-
lpad
@Deprecated public static String lpad(String s, @org.checkerframework.checker.index.qual.NonNegative int length) Deprecated.Returns a string of the specified length, truncated if necessary, and padded with spaces to the left if necessary.- Parameters:
s
- string to truncate or padlength
- goal length- Returns:
- s truncated or padded to length characters
-
rpad
@Deprecated public static String rpad(String s, @org.checkerframework.checker.index.qual.NonNegative int length) Deprecated.Returns a string of the specified length, truncated if necessary, and padded with spaces to the right if necessary.- Parameters:
s
- string to truncate or padlength
- goal length- Returns:
- s truncated or padded to length characters
-
rpad
@Deprecated public static String rpad(int num, @org.checkerframework.checker.index.qual.NonNegative int length) Deprecated.Converts the int to a String, then formats it usingrpad(String,int)
.- Parameters:
num
- int whose string representation to truncate or padlength
- goal length- Returns:
- a string representation of num truncated or padded to length characters
-
rpad
@Deprecated public static String rpad(double num, @org.checkerframework.checker.index.qual.NonNegative int length) Deprecated.Converts the double to a String, then formats it usingrpad(String,int)
.- Parameters:
num
- double whose string representation to truncate or padlength
- goal length- Returns:
- a string representation of num truncated or padded to length characters
-
count
Deprecated.Returns the number of times the character appears in the string.- Parameters:
s
- string to search inch
- character to search for- Returns:
- number of times the character appears in the string
-
count
Deprecated.Returns the number of times the second string appears in the first.- Parameters:
s
- string to search insub
- non-empty string to search for- Returns:
- number of times the substring appears in the string
-
abbreviateNumber
Deprecated.Convert a number into an abbreviation such as "5.00K" for 5000 or "65.0M" for 65000000. K stands for 1000, not 1024; M stands for 1000000, not 1048576, etc. There are always exactly 3 decimal digits of precision in the result (counting both sides of the decimal point).- Parameters:
val
- a numeric value- Returns:
- an abbreviated string representation of the value
-
countFormatArguments
Deprecated.Returns the number of arguments that the given format string takes. This is the number of specifiers that take arguments (some, like%n
and%%
, do not take arguments).- Parameters:
s
- a string- Returns:
- the number of format specifiers in the string
-
tokens
Deprecated.Returns a ArrayList of the Strings returned byStringTokenizer(String,String,boolean)
with the given arguments.The static type is
ArrayList<Object>
because StringTokenizer extendsEnumeration<Object>
instead ofEnumeration<String>
as it should (probably due to backward-compatibility).- Parameters:
str
- a string to be parseddelim
- the delimitersreturnDelims
- flag indicating whether to return the delimiters as tokens- Returns:
- vector of strings resulting from tokenization
-
tokens
Deprecated.Returns a ArrayList of the Strings returned byStringTokenizer(String,String)
with the given arguments.- Parameters:
str
- a string to be parseddelim
- the delimiters- Returns:
- vector of strings resulting from tokenization
-
tokens
Deprecated.Returns a ArrayList of the Strings returned byStringTokenizer(String)
with the given arguments.- Parameters:
str
- a string to be parsed- Returns:
- vector of strings resulting from tokenization
-
sleep
Deprecated.Like Thread.sleep, but does not throw any checked exceptions, so it is easier for clients to use. Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds.- Parameters:
millis
- the length of time to sleep in milliseconds
-
usedMemory
Deprecated.Returns the amount of used memory in the JVM.To force a garbage collection, which gives a more accurate overapproximation of the memory used, but is also slower, use
usedMemory(boolean)
- Returns:
- the amount of used memory
-
usedMemory
Deprecated.Returns the amount of used memory in the JVM.- Parameters:
forceGc
- if true, force a garbage collection, which gives a more accurate overapproximation of the memory used, but is also slower- Returns:
- the amount of used memory
-
gc
Deprecated.useSystemPlume.gc()
Perform garbage collection. Like System.gc, but waits to return until garbage collection has completed. -
backTrace
Deprecated.Returns a String representation of the backtrace of the given Throwable. To see a backtrace at the current location, dobacktrace(new Throwable())
.- Parameters:
t
- the Throwable to obtain a backtrace of- Returns:
- a String representation of the backtrace of the given Throwable
-
stackTraceToString
Returns a String representation of the stack trace (the backtrace) of the given Throwable. For a stack trace at the current location, dostackTraceToString(new Throwable())
.- Parameters:
t
- the Throwable to obtain a stack trace of- Returns:
- a String representation of the stack trace of the given Throwable
-
StringsPlume.NullableStringComparator