Here is the code:
P para = factory.createP(); R run = factory.createR(); Text text = factory.createText(); text.setValue( \" abc
You need to tell docx4j to explicitly preserve whitespace in your Text instances (the underlying format is XML of course, which tends not to pay much heed to whitespace). Something like this:
Text
text.setValue(" abc "); text.setSpace("preserve"); ...