Java and Windows - error: illegal escape character

前端 未结 6 1168
失恋的感觉
失恋的感觉 2021-01-14 06:04

I have done my .java file that changes registry data. But I am getting \"illegal escape character\" error on the line where Runtime.getRuntime().exec exists. Wh

6条回答
  •  遥遥无期
    2021-01-14 06:21

    You need to escape the backslash characters in your registry path string:

    "REG ADD `HKCU\\Software\\ ...
    

    The backslash character has a special meaning in strings: it's used to introduce escape characters. if you want to use it literally in a string, then you'll need to escape it, by using a double-backslash.

提交回复
热议问题