aspose file tools
The moose likes Java in General and the fly likes Does anyone know if there is an escape character that represents a space? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Does anyone know if there is an escape character that represents a space? " Watch "Does anyone know if there is an escape character that represents a space? " New topic
Author

Does anyone know if there is an escape character that represents a space?

James Hodgkiss
Ranch Hand

Joined: Jan 22, 2004
Posts: 401
Hiya Steven,

Yes, I mean like \n.

It's for a j2me project I'm working on where I need to retrieve some Strings from a messages.properties files where the first characters of the Strings are spaces.

Cheers,
James
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
Hit the wrong button? You should have just replied.

Anyways, you don't need an escape character for space like you have for \n. Just put a space in the String. " value"
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
If the first character of a value in a properties file is a white space, you need to escape it using a backslash.

See the JavaDoc for Properties.load for more detailed explanation.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
James Hodgkiss
Ranch Hand

Joined: Jan 22, 2004
Posts: 401
Cheers guys.

Yeah, I hit the wrong button. (I was wondering why I had to enter the message subject again... )

There are no double apostrophes in the properties file, hence leading spaces aren't detected. But I had a look at the Properties javadoc, and the escape sequence for a space is "\ ", so my properties file entry is now like:

thisKey = \ \ \ some string where the first three chars are spaces!

Thanks again,
James
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Does anyone know if there is an escape character that represents a space?
 
Similar Threads
Using commandline arguments Query
'+' operator overloading in java
JDBC Resources
Any design patter for this ??
Conversion of string into an expression