Here you can find the source of rightPad(String strInput, int intLength)
Parameter | Description |
---|---|
strInput | string to be right padded |
intLength | right pad the input string to intLength( in bytes ) |
public static String rightPad(String strInput, int intLength)
//package com.java2s; /*/*from w w w . ja v a2 s .c o m*/ * File: $RCSfile$ * * Copyright (c) 2005 Wincor Nixdorf International GmbH, * Heinz-Nixdorf-Ring 1, 33106 Paderborn, Germany * All Rights Reserved. * * This software is the confidential and proprietary information * of Wincor Nixdorf ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered * into with Wincor Nixdorf. */ public class Main { /** * Pad " " to String right side. * * @param strInput string to be right padded * @param intLength right pad the input string to intLength( in bytes ) * @return the string after right padding */ public static String rightPad(String strInput, int intLength) { byte[] byteResult = new byte[intLength]; byte[] byteInput = strInput.getBytes(); System.arraycopy(byteInput, 0, byteResult, 0, byteInput.length); for (int i = byteInput.length; i < intLength; i++) { byteResult[i] = ' '; } return new String(byteResult); } }