Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Left Pad String With Spaces in Java

When you work on a program or create a system that requires you to pad a String using spaces, all you need to do is to consider the width of a String. If the width is less than the target length, you can pad the String with spaces to guarantee the length of that String. Java Left Pad String with spaces is important specially when interfacing with older systems like a mainframe, where deciding which part of data is defined by number of characters, instead of more sophisticated way like XML or JSON format.



This post first appeared on Grails Cookbook, please read the originial post: here

Share the post

Left Pad String With Spaces in Java

×

Subscribe to Grails Cookbook

Get updates delivered right to your inbox!

Thank you for your subscription

×