Is any method in Java automatically alcipising the string? Just in Java, no other libraries.
Thank you.
In case, depending on your usage, it may be useful to keep the straps between letters ( I.e. adding characters in the end to provide some context):
/ ** * In the input strings, the oval is more than the maximum. Low wire or * faucet is back unchanged. * @PRAM Input Input String which may be subjected to reduced * @ Ultimate Maxcaptors Maximum characters that are acceptable for dissatisfied string. Must be at least 3, otherwise a string with elusive is already too long. * After the ultimate characters, the number of alphabetic alphabets that should be visible after the elipisis (0 or greater) * Backwards altitudes * Back to the truncated string with the public static string alesize (String input, int maxcatter, int worksappear alps) {If (maxCharacters & lt; 3) (Exceptions to remove new illegal conclusions ("Maxcharacters should be at least 3 because the alipasis already takes 3 characters");} if (Maxcars - 3 & g T; characters intermittently) {To set new invalid records ("after the characters the alps must be less than maximum faces");} if (input == faucet} input length () & lt; maxCharacters) {return input;} Return Input.substring (0, Max Creator - 3 - Alphabets Alps) + "..." + input.slstring (input.length () - charactersAfterEllipsis);} There are also more sophisticated features Those who want the alipasis algorithm from you: If you have to keep the text in a graphical element and you use the proportional font If you are using, then you will have to measure the length of the string.
For swing / AWT which will be java.awt.Font.getStringBounds . In this situation, a simple algorithm will cut one letter one letter at a time and add oval, until the string gets fit in the given range. If used often, then the bifurcation method (expanded in C #, but should be easy to translate into Java) can save some processor cycles.
Comments
Post a Comment