package com.rib.icop.util;
public class RibStringUtils {
/**
* 将String前补0,补全为指定的位数
* @param src
* @param targetLength
* @return
*/
public static String preCompleteWithZero(String src, int targetLength) {
StringBuffer tmp = new StringBuffer();
int currentLength = src.length();
for (int i = 0; i < targetLength - currentLength; i++) {
tmp.append("0");
}
return tmp.append(src).toString();
}
/**
* 将String前补空格,补全为指定的位数
* @param src
* @param targetLength
* @return
*/
public static String postCompleteWithBlank(String src, int targetLength) {
StringBuffer tmp = new StringBuffer();
tmp.append(src);
int currentLength = src.length();
for (int i = 0; i < targetLength - currentLength; i++) {
tmp.append(" ");
}
return tmp.toString();
}
}