Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java string padding

Have a look at org.apache.commons.lang.StringUtils#rightPad(String str, int size, char padChar).

But the algorithm is very simple (pad right up to size chars):

public String pad(String str, int size, char padChar)
{
  StringBuilder padded = new StringBuilder(str);
  while (padded.length() < size)
  {
    padded.append(padChar);
  }
  return padded.toString();
}
Comment

PREVIOUS NEXT
Code Example
Java :: WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 
Java :: loop through string in java 
Java :: indexoutofboundsexception java 
Java :: java import text file into arraylist 
Java :: java random uuid 
Java :: How to do press enter to continue in java 
Java :: android studio Clearing shared preferences; 
Java :: android translate string java 
Java :: 64 encode java 
Java :: how to get width android 
Java :: enum type spring boot entity 
Java :: convert array to list java 
Java :: javafx how to change shape color 
Java :: getting the last value of an integer in java 
Java :: fill an array with random numbers between 1 and 100 java 
Java :: convert int[] to list java 
Java :: java lowercase 
Java :: java loop array backwards 
Java :: string to bigdecimal 
Java :: java terminal colors 
Java :: Do not concatenate text displayed with setText. Use resource string with placeholders. 
Java :: java get date in utc 
Java :: java how to make a number 
Java :: on touch listener android 
Java :: iterable interface in java 
Java :: How to determine if a binary tree has a certain root to leaf target sum value, in Java? 
Java :: max int in java 
Java :: find number of occurrences of a substring in a string java 
Java :: arrays in java 
Java :: date minus date java 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =