Wednesday January 21, 2015, 14:30-15:00 Lab 02 Version D
/**
* Test 1 utility class that provides fields and methods for working with
* strings.
*
*/
public class TestD {
/**
* The string equal to a single space " "
*/
public static final String SPACE = " ";
/**
* The string equal to the tab character.
*/
public static final String TAB = "\t";
/**
* Returns a new string formed by replacing each TestD.SPACE in s with
* TestD.TAB. Returns the empty string if s is null.
*
* @param s
* a string to search for spaces
* @return a new string with tabs replacing spaces in s, or
* the empty string if s is null
*
*/
public static String spacesToTabs(String s) {
if (s == null) {
return "";
}
return s.replaceAll(TestD.SPACE, TestD.TAB);
}
private TestD() {
}
}