Need urgent help regarding java word wrap function.. URGENT
i have a doubt regarding word wrap in java. Here is the code i have written....
************************************************** ****************************************
public String Enter_LF_into_content(String inbound, Container container) {
String outbout = "";
int counter = inbound.length()/128;
for (int a=0;a<counter;a++)
{
outbound=outbound.concat(inbound.substring(a*128,( a+1)*128)).concat("\n");
}
outbound=outbound.concat(inbound.substring(counter *128));
return outbound;
}
************************************************** ************************
the above code wraps up string from 128th character but the problem is, it doesnt take care of the words it simply cuts the string from 128th position.
I need some custom code which can wrap the string by taking care of the words.
Plz guyzzzz.... i need help... its very urgent....
Re: Need urgent help regarding java word wrap function.. URGENT
java text wrapping - Google Search
Is there a text wrap function in the java standard library? - Stack Overflow - there is no Java line wrapping
How to Use Text Areas (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components) - there is Java line wrapping
If you really have to write that code yourself and your requirement is only to wrap console text, try using String.lastIndexOf(int, int) and finding the position of the last space from your right margin (your text width) in your to-be-wrapped text, and breaking the text there.
Re: Need urgent help regarding java word wrap function.. URGENT
Hi Sean,
Thank you for the reply. Actually i am an SAP ABAPer and there is a little requirement which can be full filled using java only.
Can you please provide a little addition in above code that if the 128th character is not space then the code should proceed to the next character untill it finds the space. once the space is found, the code would remember the position and cut the string from there.
This whole procedure will be in loop unless the whole string is covered and every loop will begin with 128 character size and will increase upto the first occurrence of space after 128 character. Thank you in advance.
Re: Need urgent help regarding java word wrap function.. URGENT
Quote:
Can you please provide a little addition in above code
If you need little bits of code to be produced urgently, your best option is probably something like liveperson.com