• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!