Results 1 to 2 of 2
- 01-14-2009, 04:47 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 42
- Rep Power
- 0
Using PadRight but want to actually cut the string off at that length
Hi all,
I am using the PadRight method I found online in order to pad a string by 'x' number of characters to the right.
here is the method:
If my string is longer than the number of characters I want to pad it by, then I want the string to be cut short.Java Code:public static String padRight(String s, int n) { return String.format("%1$-" + n + "s", s); }
This is my call to that method:
but very occassionally the result of rs.GetString(2) is longer than the 11 characters I specify in the call.Java Code:padRight(rs.getString(3), 11)
When this happens I want the string to me NO MORE than 11.
Can anybody advise?
Thanks and Regards,
Matt
- 01-14-2009, 05:19 PM #2
Member
- Join Date
- Sep 2008
- Posts
- 42
- Rep Power
- 0
Similar Threads
-
[SOLVED] String Length issue.
By ChrisMayhew in forum New To JavaReplies: 7Last Post: 01-11-2009, 03:16 AM -
what does num.length method does?
By kris09 in forum New To JavaReplies: 1Last Post: 08-07-2008, 10:19 PM -
Integer length
By jithan in forum New To JavaReplies: 1Last Post: 06-12-2008, 03:35 PM -
Finding the exact length of a string in a JLabel (in pixels)
By Clarkey in forum Advanced JavaReplies: 2Last Post: 03-25-2008, 05:49 AM -
Help with method length
By toby in forum New To JavaReplies: 1Last Post: 07-25-2007, 08:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks