Java String Format array -


i trying format string follows

system.out.println("unique number :"+ number[b]); system.out.println("unique number formatted 28  :"+ string.format("%-28s",number[b]).replace(' ','0')) 

there no issue when "number" string shorter 28, adds 0's left, when string longer 28 dosnt shorten it, doing wrong ?

its extract loop btw

many thanks

the formatter doesn't cut string, makes sure uses @ least 28 spaces.

you have like:

if (str.length() > 28) {     str = str.substring(0, 28); } 

or maybe

if (str.length() > 28) {     str = str.substring(str.length() - 28, str.length()); } 

to limit size.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -