This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Remove unwanted chars (new line,tab) in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Remove unwanted chars (new line,tab) in java" Watch "Remove unwanted chars (new line,tab) in java" New topic
Author

Remove unwanted chars (new line,tab) in java

sujith delpachithra
Greenhorn

Joined: Oct 14, 2008
Posts: 12
i am using informix server as my database. i have some data in it with dirty values like new line chars,tab chars etc.

i want to remove those from my database.

Please, reply.
Arka Guhathakurta
Ranch Hand

Joined: Mar 01, 2009
Posts: 46
copy the content to a string variable and then use trim method to remove unwanted spaces from either side of the string.
Note that trim will not remove whitespace chars inside the string between words.
I hope it helps.


regards,
Arka
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

If you want to remove the spaces from the middle of the string too, you can use the replaceAll method of String class with a regex like \s to replace all the space characters with anything that you like. This method would be a little slow if you want to update all the records. You should try a bulk update query specific to your database to achieve that...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
wood burning stoves
 
subject: Remove unwanted chars (new line,tab) in java
 
Similar Threads
removing lines
Find Hex chars in a file
Best strategy for handling actions across multiple windows?
delete and insert chars inside a along string
Problem While storing Chinese Chars In db.