Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

String length with new line

807598Sep 27 2006 — edited Sep 27 2006
Hello
I post this in jsp but I think this one is more suitable:

I have a Form that allows user to fill in. In that form, I have an address field (textarea).

Now I want to know the length of this address. I uses

String size = addressField.length();

The size is correct if I have only one line in the address. But if I enter an adress with multi-line, the size is much more than what I count (by hand) even I add one value for each line.

For example, if address "Wellington" has one line as:

Wellington

It can be seen that the size is: 10

But if I enter this in multi lines:

W
e
ll
ing
ton

It can be seen that, by counting, the size is 14 (10+4=14)

However, I get the value of addressField.length() is 18

How I should get value for only 14

Many thanks
shoa
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 25 2006
Added on Sep 27 2006
13 comments
2,466 views