public class StringUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ALIGN_CENTER
Represents centered alignment.
|
static int |
ALIGN_LEFT
Represents left alignment.
|
static int |
ALIGN_RIGHT
Represents right alignment.
|
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
align(PrintWriter output,
String s,
int width,
char paddingChar,
int alignment)
Pads out a left-, right-, or center-aligned string using the specified character up to the specified width.
|
static void |
align(PrintWriter output,
String s,
int width,
int alignment)
Pads out a left-, right-, or center-aligned string using spaces up to the specified width.
|
static String |
align(String s,
int width,
char paddingChar,
int alignment)
Pads out a left-, right-, or center-aligned string using the specified character up to the specified width.
|
static String |
align(String s,
int width,
int alignment)
Pads out a left-, right-, or center-aligned string using spaces up to the specified width.
|
static String |
multiply(char c,
int count)
Duplicates the given character
count times. |
static void |
multiply(PrintWriter output,
char c,
int count)
Duplicates the given character
count times to the Writer. |
static void |
multiply(PrintWriter output,
String s,
int count)
Duplicates the given string
count times to the Writer. |
static String |
multiply(String s,
int count)
Duplicates the given string
count times. |
static void |
prependEachLine(PrintWriter output,
String s,
String prependWith)
Prepends a specific string to the front of each line of an input string.
|
static String |
prependEachLine(String s,
String prependWith)
Prepends a specific string to the front of each line of an input string.
|
public static final int ALIGN_LEFT
public static final int ALIGN_CENTER
public static final int ALIGN_RIGHT
public static String align(String s, int width, int alignment)
s
- String to padwidth
- Minimum width of final stringalignment
- How to align the string < 0 means left, 0 means center, and > 0 means rightpublic static String align(String s, int width, char paddingChar, int alignment)
s
- String to padwidth
- Minimum width of final stringpaddingChar
- Character to pad withalignment
- How to align the string < 0 means left, 0 means center, and > 0 means rightpublic static void align(PrintWriter output, String s, int width, int alignment)
output
- Writer to output the centered string tos
- String to padwidth
- Minimum width of final stringalignment
- How to align the string < 0 means left, 0 means center, and > 0 means rightpublic static void align(PrintWriter output, String s, int width, char paddingChar, int alignment)
output
- Writer to output the centered string tos
- String to padwidth
- Minimum width of final stringpaddingChar
- Character to pad withalignment
- How to align the string < 0 means left, 0 means center, and > 0 means rightpublic static String multiply(char c, int count)
count
times.
If count
is less than or equal to 0, the empty string is returned.c
- Character to duplicatecount
- Number of times to duplicatepublic static String multiply(String s, int count)
count
times.
If count
is less than or equal to 0, the empty string is returned.s
- String to duplicatecount
- Number of times to duplicatepublic static void multiply(PrintWriter output, char c, int count)
count
times to the Writer.
If count
is less than or equal to 0, this is a no-op.output
- Writer to receive duplicated resultsc
- Character to duplicatecount
- Number of times to duplicatepublic static void multiply(PrintWriter output, String s, int count)
count
times to the Writer.
If count
is less than or equal to 0, this is a no-op.output
- Writer to receive duplicated resultss
- String to duplicatecount
- Number of times to duplicatepublic static String prependEachLine(String s, String prependWith)
'\n'
, '\r'
, or '\f'
character.s
- The input string.prependWith
- The string to prepend to each line.public static void prependEachLine(PrintWriter output, String s, String prependWith)
'\n'
, '\r'
, or '\f'
character.output
- The writer to recieve the modified string.s
- The input string.prependWith
- The string to prepend to each line.Copyright © 2017. All rights reserved.