This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Writing to .properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Writing to .properties file" Watch "Writing to .properties file" New topic
Author

Writing to .properties file

Subhendu Dash
Greenhorn

Joined: Mar 24, 2011
Posts: 18
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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing to .properties file