Try this
{

String desiredstring ="", string1 ="";
string1="column_name";
desiredstring = string1;

if ( string1.length() != 35 )
{
desiredstring = string1 + "00000000000000000000000000000000000000";
desiredstring = desiredstring.substring(0,35);
System.out.println("Desired String Length is "+desiredstring.length()+"
"+desiredstring);
}

If this looks OK to you , replace zeroes with equal number of spaces

Hope this helps
Santosh








B R Nair <[EMAIL PROTECTED]> on 07/28/2000 09:26:13 AM

Please respond to A mailing list about Java Server Pages specification and
      reference <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:    (bcc: Santosh Daryani/IT/Aon Consulting)

Subject:  Proprtionate String Padding



Hello,

How can I pad a string with variable spaces?


When I query a database, the columns I get are not of fixed length. I would
like to make it uniform length. Is there any short cut to add spaces at the
end of a string? In other words can anyone give me the Java equivalent to
this pseudo code?

desiredString = string1 +  (35 - string1.length()) spaces.

Thanks in advance
BRN

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to