Class UtilPlume
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDeprecated.static classDeprecated.static final classDeprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringabbreviateNumber(long val) Deprecated.static @Nullable StringappendProperty(Properties p, String key, String value) Set the property to its previous value concatenated to the given value.static StringExecute the given command, and return all its output as a string.static StringExecute the given command, and return all its output as a string.static StringDeprecated.static BufferedOutputStreambufferedFileOutputStream(String filename, boolean append) static BufferedReaderbufferedFileReader(File file) Deprecated.static BufferedReaderbufferedFileReader(File file, @Nullable String charsetName) Deprecated.static BufferedReaderbufferedFileReader(String filename) Deprecated.static BufferedReaderbufferedFileReader(String filename, @Nullable String charsetName) Deprecated.static BufferedWriterbufferedFileWriter(String filename) Deprecated.static BufferedWriterbufferedFileWriter(String filename, boolean append) Deprecated.static booleancanCreateAndWrite(File file) Deprecated.static <T> @PolyNull @PolySigned Tclone(@PolyNull @PolySigned T data) Clones the given object by callingclone()reflectively.static intDeprecated.static intDeprecated.static intDeprecated.static longcountLines(String filename) Deprecated.static FilecreateTempDir(String prefix, String suffix) Deprecated.static booleanDeprecated.static booleanDeprecated.static booleanequalFiles(String file1, String file2) Deprecated.static booleanequalFiles(String file1, String file2, boolean trimLines) Deprecated.static StringescapeJava(char c) Deprecated.static StringescapeJava(Character ch) Deprecated.static StringescapeJava(String orig) Deprecated.static StringescapeNonASCII(String orig) Deprecated.static StringDeprecated.static StringescapeNonJava(String orig) Deprecated.static FileexpandFilename(File name) Deprecated.static StringexpandFilename(String name) Deprecated.static InputStreamfileInputStream(File file) Deprecated.static InputStreamfileInputStream(Path path) Deprecated.Deprecated.static InputStreamReaderfileReader(File file) Deprecated.static InputStreamReaderfileReader(File file, @Nullable String charsetName) Deprecated.static InputStreamReaderfileReader(String filename) Deprecated.static InputStreamReaderfileReader(Path path) Deprecated.static InputStreamReaderfileReader(Path path, @Nullable String charsetName) Deprecated.static <T> TfirstNonNull(T first, T second) Return the first argument if it is non-null, otherwise return the second argument.static voidgc()Deprecated.useSystemPlume.gc()static booleangetBooleanProperty(Properties p, String key) Determines whether a property has a string value that represents true: "true", "yes", or "1".static booleangetBooleanProperty(Properties p, String key, boolean defaultValue) Determines whether a property has a string value that represents true: "true", "yes", or "1".static inthash(double x) Deprecated.static inthash(double @Nullable [] a) Deprecated.static inthash(double @Nullable [] a, double @Nullable [] b) Returns a hash of the arguments.static inthash(double a, double b) Deprecated.static inthash(double a, double b, double c) Deprecated.static inthash(long l) Deprecated.useLong.hashCode()static inthash(long @Nullable [] a) Deprecated.static inthash(long @Nullable [] a, long @Nullable [] b) Returns a hash of the arguments.static inthash(long a, long b) Deprecated.static inthash(long a, long b, long c) Deprecated.static intDeprecated.static intDeprecated.static intDeprecated.static intDeprecated.static StringindentLines(@org.checkerframework.checker.index.qual.NonNegative int indent, @Nullable Object o) Deprecated.static StringindentLinesExceptFirst(@org.checkerframework.checker.index.qual.NonNegative int indent, @Nullable Object o) Deprecated.static StringinferLineSeparator(File file) Deprecated.static StringinferLineSeparator(String filename) Deprecated.static intDeprecated.use CollectionsPlume.intersectionCardinalitystatic intintersectionCardinality(BitSet a, BitSet b, BitSet c) Deprecated.use CollectionsPlume.intersectionCardinalitystatic booleanintersectionCardinalityAtLeast(BitSet a, BitSet b, @org.checkerframework.checker.index.qual.NonNegative int i) Deprecated.use CollectionsPlume.intersectionCardinalityAtLeaststatic booleanintersectionCardinalityAtLeast(BitSet a, BitSet b, BitSet c, @org.checkerframework.checker.index.qual.NonNegative int i) Deprecated.use CollectionsPlume.intersectionCardinalityAtLeaststatic StringjavaSource(File name) Deprecated.static <T> Stringjoin(@Signed T[] a, CharSequence delim) Deprecated.usejoin(CharSequence, Object...)which has the arguments in the other orderstatic <T> Stringjoin(CharSequence delim, @Signed T... a) Deprecated.static Stringjoin(CharSequence delim, Iterable<? extends @Signed @PolyNull Object> v) Deprecated.static Stringjoin(Iterable<? extends @Signed @PolyNull Object> v, CharSequence delim) Deprecated.usejoin(CharSequence, Iterable)which has the arguments in the other orderstatic <T> StringjoinLines(@Signed T... a) Deprecated.static StringDeprecated.static LineNumberReaderlineNumberFileReader(File file) Deprecated.static LineNumberReaderlineNumberFileReader(String filename) Deprecated.static StringDeprecated.static StringmapToStringAndClass(Map<? extends @Signed @PolyNull Object, ? extends @Signed @PolyNull Object> m) static StringDeprecated.static StringprefixLines(String prefix, @Nullable Object o) Deprecated.static StringprefixLinesExceptFirst(String prefix, @Nullable Object o) static booleanpropertyIsTrue(Properties p, String key) static StringDeprecated.static StringDeprecated.static ObjectreadObject(File file) Deprecated.static StringremoveWhitespaceAfter(String arg, String delimiter) static StringremoveWhitespaceAround(String arg, String delimiter) static StringremoveWhitespaceBefore(String arg, String delimiter) static StringreplacePrefix(String target, String oldStr, String newStr) static StringreplaceString(String target, String oldStr, String newStr) Deprecated.static StringreplaceSuffix(String target, String oldStr, String newStr) static Stringrpad(double num, @org.checkerframework.checker.index.qual.NonNegative int length) Deprecated.static Stringrpad(int num, @org.checkerframework.checker.index.qual.NonNegative int length) Deprecated.static StringDeprecated.static @Nullable StringsetDefaultMaybe(Properties p, String key, String value) Set the property only if it was not previously set.static voidsleep(long millis) Deprecated.static String[]Deprecated.static String[]Deprecated.static String[]splitLines(String s) Deprecated.static StringReturns a String representation of the stack trace (the backtrace) of the given Throwable.static voidstreamCopy(InputStream from, OutputStream to) Deprecated.streamLines(InputStream stream) Deprecated.static StringDeprecated.Deprecated.Deprecated.Deprecated.static StringtoStringAndClass(@Nullable Object o) Deprecated.static StringunescapeJava(String orig) Deprecated.static StringunescapeNonJava(String orig) Deprecated.static longDeprecated.static longusedMemory(boolean forceGc) Deprecated.static voidDeprecated.static voidwriteObject(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 aFileas 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 byindentspaces.- 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 byindentspace 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 byindentspaces.- 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 byindentspace 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:
delim- delimiter to place between printed representationsa- array of values to concatenate- 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:
delim- delimiter to place between printed representationsv- collection of values to concatenate- 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%nand%%, 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