Java Utililty Methods String Format

List of utility methods to do String Format

Description

The list of methods to do String Format are organized into topic(s).

Method

StringgetTextAsFormattedLines(String text, int lineLength)
Given a chunk of text format it so that you return a new String with the line length equal to that passed in.
StringBuffer retdata = new StringBuffer();
List lines = new ArrayList();
String t = new String(text);
while (t.length() > lineLength) {
    String s = t.substring(0, lineLength);
    String rest = t.substring(lineLength);
    int lastInd = s.lastIndexOf(' ');
    if (lastInd == (lineLength)) {
...
ImageWritergetWriterByFormat(final String format)
get Writer By Format
final Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName(format);
if (iter.hasNext()) {
    return iter.next();
} else {
    throw new IllegalArgumentException("Image format [" + format + "] is not supported");
booleanisDurationFormatPattern(String formatPattern)
Determine if the duration format pattern is valid.
if (formatPattern == null) {
    return false;
final int length = formatPattern.length();
if (length < 2) {
    return false;
formatPattern = formatPattern.toLowerCase();
...
booleanisQueryInFormat(String in)
is Query In Format
if (in == null || in.isEmpty()) {
    return true;
String[] ins = in.split(","); 
return INS.containsAll(Arrays.asList(ins));
Stringstr(final String messageFormat, final Object... args)
Convenience shortcut for MessageFormat#format(String,Object) .
return MessageFormat.format(messageFormat, args);
StringStrFormat(String pattern, Object... arguments)
Str Format
Object argumentStr[] = new String[arguments.length];
for (int i = 0; i < argumentStr.length; i++) {
    argumentStr[i] = arguments[i].toString();
return MessageFormat.format(pattern, argumentStr);
StringstringFormat(String pattern, Object[] arguments)
add by chen yong 2007-2-5 samples: 1.
return MessageFormat.format(pattern, arguments);
StringstringFormat(String textPattern, Object... args)
Formats the given String of text using the String#format(String,Object) method.
return String.format(textPattern, args);