Java and windows – error: illegal escape character
•
Java
I have finished changing registry data Java file But I'm running runtime getRuntime(). An illegal escape character error was encountered on the line of exec Where was my mistake?
import java.util.*; import java.applet.Applet; import java.awt.*; class test { public static void main(String args[]) { try { Runtime.getRuntime().exec("REG ADD 'HKCU\Software\Microsoft\Internet Explorer\Main' /V 'Start Page' /D 'http://www.stackoverflow.com/' /F"); } catch (Exception e) { System.out.println("Error ocured!"); } } }
Solution
You need the backslash used in the escape path
String windowsPath = "\\Users\\FunkyGuy\\My Documents\\Hello.txt";
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码