阅读背景:

获得指定长度字符串,不足位右补空格

来源:互联网 
	/**
	 * 生成指定长度字符串,不足位右补空格
	 * @param str
	 * @param length
	 * @return
	 */
	private static String formatStr(String str, int length) {
		int strLen;
		if (str == null) {
			strLen = 0;
		}else{
			strLen= str.length();
		}
		
		if (strLen == length) {
			return str;
		} else if (strLen < length) {
			int temp = length - strLen;
			String tem = "";
			for (int i = 0; i < temp; i++) {
				tem = tem + " ";
			}
			return str + tem;
		}else{
			return str.substring(0,length);
		}
	}	/**
	 * 生成指定长度字符串,不足位右补空格
	 * @param str
	 * @



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: