Is there heredoc alternative in Java (heredoc as PHP)? [duplicate]

♀尐吖头ヾ 提交于 2019-12-18 19:07:04

问题


For JAVA development I need writing to a files with strings like "\r\t\n <>", because from Java I want writing a PHP file. If you can't understand look at this example:

BufferedWriter buffW = new BufferedWriter(fileW);
            buffW.write("<?php\n\n\tclass MyClass {\n\tpublic function test()\n}\n}\n?>");

This is mess a code, I want to write a clean such as PHP can do, but can't find on Java alternative way as example:

 <?php
$mystring = <<<EOT
    This is some PHP text.
    It is completely free
    I can use "double quotes"
    and 'single quotes',
    plus $variables too, which will
    be properly converted to their values,
    you can even type EOT, as long as it
    is not alone on a line, like this:
EOT;
?> 

回答1:


Is there a heredoc equivalent in Java?

No, there is no direct heredoc alternative in the Java programming language.

Check this similar question.



来源:https://stackoverflow.com/questions/15189679/is-there-heredoc-alternative-in-java-heredoc-as-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!