Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://www.aoindustries.com/contact
public final class StringUtility extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
buildEmailList(String[] list)
Deprecated.
This method is no longer used and will be removed.
|
static String |
buildList(Iterable<?> objects)
Deprecated.
Please use
join(objects, ", ") instead. |
static String |
buildList(Object[] objects)
Deprecated.
Please use
join(objects, ", ") instead. |
static String |
buildList(String[] list)
Deprecated.
Please use
join(objects, ", ") instead. |
static int |
compareToDDMMYYYY(String date1,
String date2)
Compare one date to another, must be in the DDMMYYYY format.
|
static int |
compareToIgnoreCaseCarefulEquals(String S1,
String S2)
Compares two strings in a case insensitive manner.
|
static boolean |
containsIgnoreCase(String line,
String word) |
static byte[] |
convertByteArrayFromHex(char[] hex) |
static int |
convertIntArrayFromHex(char[] hex) |
static long |
convertLongArrayFromHex(char[] hex) |
static long |
convertStringDateToTime(String date) |
static String |
convertToHex(byte[] bytes) |
static void |
convertToHex(byte[] bytes,
Appendable out) |
static String |
convertToHex(int value)
Converts an int to a full 8-character hex code.
|
static void |
convertToHex(int value,
Appendable out)
Converts an int to a full 8-character hex code.
|
static String |
convertToHex(long value)
Converts a long integer to a full 16-character hex code.
|
static void |
convertToHex(long value,
Appendable out)
Converts a long integer to a full 16-character hex code.
|
static int |
countOccurances(byte[] buff,
int len,
String word)
Deprecated.
Corrected spelling
|
static int |
countOccurances(byte[] buff,
String word)
Deprecated.
Corrected spelling
|
static int |
countOccurances(String line,
String word)
Deprecated.
Corrected spelling
|
static int |
countOccurrences(byte[] buff,
int len,
String word)
Counts how many times a word appears in a line.
|
static int |
countOccurrences(byte[] buff,
String word)
Counts how many times a word appears in a line.
|
static int |
countOccurrences(String line,
String word)
Counts how many times a word appears in a line.
|
static String |
escapeSQL(String s)
Deprecated.
Please use SQLUtility.escapeSQL(s.replace('*', '%'))
|
static String |
firstLineOnly(String value,
int maxCharacters)
Returns the first line only, and only up to the maximum number of characters.
|
static String |
getApproximateBitRate(long bit_rate)
Gets the approximate bit rate (where k=1000) in this format:
x
xx
xxx
x.x k
xx.x k
xxx k
x.x M
xx.x M
xxx M
x.x G
xx.x G
xxx G
x.x T
xx.x T
xxx T
xxx...
|
static String |
getApproximateSize(long size)
Gets the approximate size (where k=1024) of a file in this format:
x byte(s)
xx bytes
xxx bytes
x.x k
xx.x k
xxx k
x.x M
xx.x M
xxx M
x.x G
xx.x G
xxx G
x.x T
xx.x T
xxx T
xxx...
|
static Date |
getDateMMDDYYYY(String date)
Converts a date in a the format MMDDYYYY to a
Date. |
static String |
getDateString(Date date)
Deprecated.
Please use SQLUtility.getDate(date.getTime())
|
static String |
getDateString(long time)
Deprecated.
Please use SQLUtility.getDate(long)
|
static String |
getDateStringMMDDYYYY(Date date)
Deprecated.
Please use SQLUtility.getDate(date.getTime())
|
static String |
getDateStringSecond(long time)
Deprecated.
Please use SQLUtility.getDateTime(long)
|
static String |
getDateStringSecond(String time)
Deprecated.
Please use SQLUtility.getDateTime(long)
|
static String |
getDecimalTimeLengthString(long time) |
static String |
getDecimalTimeLengthString(long time,
boolean alwaysShowMillis) |
static int |
getHex(char ch)
Converts one hex digit to an integer
|
static char |
getHexChar(int v)
Gets the hexadecimal character for the low-order four bits of the provided int.
|
static String |
getMonth(int month)
Deprecated.
This method is not locale-aware, is no longer used, and will be removed.
|
static String[] |
getStringArray(List<?> V)
Deprecated.
Please use List.toArray(Object[])
|
static String |
getTimeLengthString(long time) |
static int |
indexOf(String S,
char[] chars)
Finds the first occurrence of any of the supplied characters
|
static int |
indexOf(String S,
char[] chars,
int start)
Finds the first occurrence of any of the supplied characters starting at the specified index.
|
static int |
indexOf(String source,
String target,
int fromIndex,
int toIndex)
Finds the next of a substring like regular String.indexOf, but stops at a certain maximum index.
|
static String |
intern(String S)
Deprecated.
Use InternUtils instead.
|
static boolean |
isValidDate(String date)
Deprecated.
Please use Calendar class instead.
|
static String |
join(Iterable<?> objects,
String delimiter)
Joins the string representation of objects on the provided delimiter.
|
static String |
join(Object[] objects,
String delimiter)
Joins the string representation of objects on the provided delimiter.
|
static boolean |
leapYear(int year)
Deprecated.
Please use Calendar class instead.
|
static String |
nullIfEmpty(String value)
Returns null if the string is null or empty.
|
static String |
removeChars(String S,
char ch)
Deprecated.
this method is slow and no longer supported
|
static String |
removeChars(String S,
char[] chars)
Deprecated.
this method is slow and no longer supported
|
static void |
replace(StringBuffer sb,
String find,
String replacement)
Replaces all occurrences of a String with a String.
|
static void |
replace(StringBuilder sb,
String find,
String replacement)
Replaces all occurrences of a String with a String.
|
static String |
replace(String string,
char ch,
String replacement)
Replaces all occurrences of a character with a String
|
static String |
replace(String string,
String find,
String replacement)
Replaces all occurrences of a String with a String
Please consider the variant with the Appendable for higher performance.
|
static void |
replace(String string,
String find,
String replacement,
Appendable out)
Replaces all occurrences of a String with a String, appends the replacement
to
out. |
static List<String> |
splitLines(String S)
Splits a String into lines on any '\n' characters.
|
static String[] |
splitString(String line)
Splits a
String into a String[]. |
static List<String> |
splitString(String line,
char delim)
Splits a string on the given delimiter.
|
static int |
splitString(String line,
char[][][] buff)
Splits a
String into a String[]. |
static <C extends Collection<String>> |
splitString(String line,
char delim,
C words)
Splits a string on the given delimiter.
|
static List<String> |
splitString(String line,
int begin,
int end,
char delim)
Splits a string on the given delimiter over the given range.
|
static <C extends Collection<String>> |
splitString(String line,
int begin,
int end,
char delim,
C words)
Splits a string on the given delimiter over the given range.
|
static List<String> |
splitString(String line,
String delim) |
static int |
splitString(String line,
String[][] buff)
Splits a
String into a String[]. |
static List<String> |
splitStringCommaSpace(String line)
Splits a string into multiple words on either whitespace or commas
|
static String |
wordWrap(String string,
int width)
Deprecated.
Use new version with Appendable for higher performance
|
static void |
wordWrap(String string,
int width,
Appendable out)
Word wraps a
String to be no longer than the provided number of characters wide. |
@Deprecated public static String getMonth(int month)
@Deprecated public static String buildEmailList(String[] list)
String[].@Deprecated public static String buildList(String[] list)
join(objects, ", ") instead.String[].@Deprecated public static String buildList(Object[] objects)
join(objects, ", ") instead.Object[].@Deprecated public static String buildList(Iterable<?> objects)
join(objects, ", ") instead.Iterable.public static String join(Iterable<?> objects, String delimiter) throws ConcurrentModificationException
ConcurrentModificationException - if iteration is not consistent between passespublic static String join(Object[] objects, String delimiter) throws ConcurrentModificationException
ConcurrentModificationException - if iteration is not consistent between passespublic static int compareToDDMMYYYY(String date1, String date2)
public static long convertStringDateToTime(String date) throws IllegalArgumentException
IllegalArgumentException@Deprecated public static int countOccurances(byte[] buff, int len, String word)
public static int countOccurrences(byte[] buff,
int len,
String word)
@Deprecated public static int countOccurances(byte[] buff, String word)
public static int countOccurrences(byte[] buff,
String word)
@Deprecated public static int countOccurances(String line, String word)
public static int countOccurrences(String line, String word)
@Deprecated public static String escapeSQL(String s)
SQLUtility.escapeSQL(String)public static Date getDateMMDDYYYY(String date) throws NumberFormatException, IllegalArgumentException
Date.date - a String containing the date in MMDDYYYY format.null if date is null, a java.sql.Date
otherwiseNumberFormatExceptionIllegalArgumentException@Deprecated public static String getDateString(long time)
SQLUtility.getDate(long)@Deprecated public static String getDateString(Date date)
SQLUtility.getDate(long)@Deprecated public static String getDateStringMMDDYYYY(Date date)
SQLUtility.getDate(long)@Deprecated public static String getDateStringSecond(long time)
SQLUtility.getDateTime(long)@Deprecated public static String getDateStringSecond(String time)
SQLUtility.getDateTime(long)@Deprecated public static String[] getStringArray(List<?> V)
String[] by calling the toString() method of each object in a list.List.toArray(Object[])public static String getTimeLengthString(long time)
public static String getDecimalTimeLengthString(long time)
public static String getDecimalTimeLengthString(long time, boolean alwaysShowMillis)
public static int indexOf(String S, char[] chars)
S - the String to searchchars - the characters to look for-1 if none foundpublic static int indexOf(String S, char[] chars, int start)
S - the String to searchchars - the characters to look forstart - the starting index.-1 if none found@Deprecated public static boolean isValidDate(String date)
Calendar@Deprecated public static boolean leapYear(int year)
Calendar@Deprecated public static String removeChars(String S, char[] chars)
char from a String@Deprecated public static String removeChars(String S, char ch)
char from a Stringpublic static String replace(String string, char ch, String replacement)
public static String replace(String string, String find, String replacement)
public static void replace(String string, String find, String replacement, Appendable out) throws IOException
out.IOExceptionpublic static void replace(StringBuffer sb, String find, String replacement)
public static void replace(StringBuilder sb, String find, String replacement)
public static List<String> splitLines(String S)
public static int splitString(String line, char[][][] buff)
String into a String[].public static int splitString(String line, String[][] buff)
String into a String[].public static List<String> splitString(String line, char delim)
public static <C extends Collection<String>> C splitString(String line, char delim, C words)
words - the words will be added to this collection.public static List<String> splitString(String line, int begin, int end, char delim)
public static <C extends Collection<String>> C splitString(String line, int begin, int end, char delim, C words)
words - the words will be added to this collection.public static List<String> splitStringCommaSpace(String line)
line - java.lang.String@Deprecated public static String wordWrap(String string, int width)
String to be no longer than the provided number of characters wide.public static void wordWrap(String string, int width, Appendable out) throws IOException
String to be no longer than the provided number of characters wide.
TODO: Make this more efficient by eliminating the internal use of substring.IOExceptionpublic static char getHexChar(int v)
public static int getHex(char ch)
throws IllegalArgumentException
IllegalArgumentExceptionpublic static void convertToHex(byte[] bytes,
Appendable out)
throws IOException
IOExceptionpublic static String convertToHex(byte[] bytes)
public static byte[] convertByteArrayFromHex(char[] hex)
public static void convertToHex(int value,
Appendable out)
throws IOException
IOExceptionpublic static String convertToHex(int value)
public static int convertIntArrayFromHex(char[] hex)
public static void convertToHex(long value,
Appendable out)
throws IOException
IOExceptionpublic static String convertToHex(long value)
public static long convertLongArrayFromHex(char[] hex)
public static String getApproximateSize(long size)
public static String getApproximateBitRate(long bit_rate)
public static int compareToIgnoreCaseCarefulEquals(String S1, String S2)
@Deprecated public static String intern(String S)
public static int indexOf(String source, String target, int fromIndex, int toIndex)
public static String firstLineOnly(String value, int maxCharacters)
Copyright © 2000–2016 AO Industries, Inc.. All rights reserved.