How to trim a string after a specific character in java -


i have string variable in java having value:

string result="34.1 -118.33\n<!--abcdefg-->"; 

i want final string contain value:

string result="34.1 -118.33"; 

how can this? i'm new java programming language.

thanks,

you can use:

result = result.split("\n")[0]; 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -