com.croftsoft.core.lang
Class StringLib

java.lang.Object
  extended by com.croftsoft.core.lang.StringLib

public class StringLib
extends Object

A collection of static methods to manipulate java.lang.String.

Since:
1998-10-04
Version:
2001-08-15
Author:
David Wallace Croft

Field Summary
static String[] ZERO_LENGTH_STRING_ARRAY
           
 
Method Summary
static void main(String[] args)
           
static String padLeft(String s, char c, int length)
           
static String padRight(String s, char c, int length)
           
static String remove(String s, int fromIndex, int toIndex)
          Returns a String with the characters between fromIndex and toIndex removed, inclusive.
static String replace(String s, String oldSub, String newSub)
          Replaces substrings in a String.
static String[] toStringArray(String text)
          Breaks a String at the ends of lines.
static String trimToNull(String s)
          Returns null if the trimming operation results in the empty String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO_LENGTH_STRING_ARRAY

public static final String[] ZERO_LENGTH_STRING_ARRAY
Method Detail

main

public static void main(String[] args)

padLeft

public static String padLeft(String s,
                             char c,
                             int length)
See Also:
padRight(java.lang.String, char, int)

padRight

public static String padRight(String s,
                              char c,
                              int length)
See Also:
padLeft(java.lang.String, char, int)

remove

public static String remove(String s,
                            int fromIndex,
                            int toIndex)
Returns a String with the characters between fromIndex and toIndex removed, inclusive.


replace

public static String replace(String s,
                             String oldSub,
                             String newSub)
Replaces substrings in a String. Replaces every instance of oldSub in s with newSub.


toStringArray

public static String[] toStringArray(String text)
Breaks a String at the ends of lines. The original text is broken into an array of String at the end-of-line delimiters such as carriage return, linefeed, or the carriage return/linefeed pair. This is returned as an array of String without the delimiters.


trimToNull

public static String trimToNull(String s)
Returns null if the trimming operation results in the empty String.

Parameters:
s - May be null.
Returns:
Returns the argument trimmed or null if the argument is null or the argument trimmed is "".

CroftSoft Javadoc

CroftSoft Core Javadoc (2008-09-28 20:58:02)