File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes line feed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "line feed" Watch "line feed" New topic

line feed

Jim Frank

Joined: Mar 13, 2004
Posts: 27
I am getting a String from a TextArea. Ascii 10 and 9 convert to blocks
[]. I want to convert these blocks to the unicode linefeed and tab, put cannot. How would I replace these blocks with the proper unicode characters. I am using 1.3, and cannot change. Thanks
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
In 1.3 you don't get String.replace() but you can write your own using indexOf() and substring() to find the delimiters and break up the bits. Here's part of one I did in my first J++ project:

Ouch, this is pretty bad! See if you can make it a lot better by keeping the output separate from the input. This also loops until the heap explodes if "new" contains "old", eg replace "BERT" by "ROBERT".

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256

the above snippet replaces the '[' character. you can customise it accordingly to replace whichever character you want.

Life called,so here I am.<br />Cheers<br />Niki.:-)
Jim Frank

Joined: Mar 13, 2004
Posts: 27
Thanks. I can replace the block, but the Unicode character comes out as a block too. I converted to a byte array and the value is 10, but it still comes out as a block in the String. Is this a problem with 1.2, 1.3?
I use \n and other unicode values to replace what is in there.
I agree. Here's the link:
subject: line feed
It's not a secret anymore!