Java中是否有heredoc替代品(heredoc作为PHP)?

时间:2013-03-03 19:14:30

标签: java php readfile heredoc

对于JAVA开发,我需要用“\ r \ t \ n \ n<>”之类的字符串写入文件,因为从Java我想编写一个PHP文件。如果您无法理解,请查看此示例:

BufferedWriter buffW = new BufferedWriter(fileW);
            buffW.write("<?php\n\n\tclass MyClass {\n\tpublic function test()\n}\n}\n?>");
这是一个乱七八糟的代码,我想写一个干净的如PHP可以做的,但是在Java替代方式上找不到例如:

 <?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 个答案:

答案 0 :(得分:14)

  

Java中是否有heredoc等效项?

不,Java编程语言中没有直接的heredoc替代品。

检查此类question