Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing to .properties file  RSS feed

 
Subhendu Dash
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While writing to a .properties file using file output stream , i am getting an unexpected '\' escape sequence in it.How to avoid it??

Please Help
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15865
81
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does your code look like?

I'm going to guess that you did something like this:

Note that \ is an escape character in Java string literals. You know: \n means linefeed, \r means carriage return, \t means tab and so on. If you want to have a backslash in a string, you have to make it a double backslash, otherwise Java is going to interpret the backslash and the following character as an escape sequence, and \S, \P and \M are not valid escape sequences.

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!