Topic: 怎样将String定义为一个固定长度的String如FF变为00FF,F变问000F

  Print this page

1.怎样将String定义为一个固定长度的String如FF变为00FF,F变问000F Copy to clipboard
Posted by: leipub
Posted on: 2005-08-31 15:02

怎样将String定义为一个固定长度的String如FF变为00FF,F变问000F

2.Re:怎样将String定义为一个固定长度的String如FF变为00FF,F变问000F [Re: leipub] Copy to clipboard
Posted by: Julian13
Posted on: 2005-09-01 11:19

there should be no standard ways to do it.

but to pad the String in fixed length, you can reuse the StringUtils from Apache Commons-Lang (http://jakarta.apache.org/commons/lang/)

there is a operation "leftPad" serve the purpose. sth like

paddedValue = StringUtils.leftPad(yourValue, 4, "0");


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923