0

I am trying to write a string to a batch file using Java Filewriter as following

fw.write("echo Default is: %SDK_ROOT%\\tools\\android-ndk-r10d\r\n");

It gives me the output as :

 echo Default is: %HEXAGON_SDK_ROOT%    ools\android-ndk-r10d

Its interpreting \tools as a tab space and ools. how to suppress the actual meaning of \t here ?

My desired output should be

echo            Default is: %HEXAGON_SDK_ROOT%\tools\android-ndk-r10d

what can I do here ?

Mofi
  • 46,139
  • 17
  • 80
  • 143
chenna
  • 159
  • 1
  • 4
  • 14
  • 2
    You just need to escape the backslash, as you always do in a string literal: `"echo Default is: %SDK_ROOT%\\tools\\android-ndk-r10d\r\n");` This has nothing to do with `FileWriter` really - it's just a normal string literal. – Jon Skeet Nov 30 '15 at 07:01
  • Have a look at http://stackoverflow.com/questions/19762169/forward-slash-or-backslash – Daniël van den Berg Nov 30 '15 at 07:08

1 Answers1

0

Add \ in front of each of your backslashes. They need to be duplicated inside string literals.

user207421
  • 305,947
  • 44
  • 307
  • 483
Jeremy
  • 776
  • 1
  • 7
  • 18