Java Utililty Methods String Left Align

List of utility methods to do String Left Align

  1. HOME
  2. Java
  3. S
  4. String Left Align

Description

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

Method

String leftAlign(int totalWidth, String s)
left Align
return String.format("%1$-" + totalWidth + "s", s);
String leftAlign(String s, int width)
left Align
String r = s;
int n = width - s.length();
for (int i = 0; i < n; i++) {
 r += ' ';
return r;
String leftAlign(String text, int width)
Appends spaces until length of text is at least width.
return rightPad(text, width, ' ');
StringBuilder leftAlign(StringBuilder in, int len)
Left aligns some text in a StringBuilder N.B.
int sfx = len - in.length();
if (sfx <= 0) {
 return in;
if (sfx > SPACES_LEN) {
 sfx = SPACES_LEN;
in.append(SPACES.substring(0, sfx));
...

AltStyle によって変換されたページ (->オリジナル) /