20

对于 JAVA 开发,我需要使用诸如“\r\t\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;
?> 
4

1 回答 1

16

heredocJava中是否有等价物?

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

检查这个类似的问题

于 2013-03-03T19:18:49.593 回答