简体   繁体   中英

System.setProperty: Invalid Escape Sequence

Im trying to make a reference to a bin.

System.setProperty("mbrola.base", "C:\Users\Name\Desktop\FreeTTS\MBrola Project"); 

But Im getting this error:

Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )

You want actual backslashes, which are usually part of escape sequences. You must escape the backslashes themselves, with another backslash.

System.setProperty("mbrola.base", "C:\\Users\\Name\\Desktop\\FreeTTS\\MBrola Project"); 

Yes, because this isn't a valid string literal:

"C:\Users\Name\Desktop\FreeTTS\MBrola Project"

You need to escape the backslashes:

"C:\\Users\\Name\\Desktop\\FreeTTS\\MBrola Project"

The string itself will only have the single backslashes though - you're just escaping it in source code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM