java - Java 中是否有 heredoc 替代方案(heredoc 作为 PHP)?

标签 java php readfile heredoc

<分区>

对于 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;
?> 

最佳答案

Is there a heredoc equivalent in Java?

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

检查这个类似的question .

关于java - Java 中是否有 heredoc 替代方案(heredoc 作为 PHP)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15189679/

相关文章:

php - 如何执行以下插入,mysql

php - MySQL查询,计算可用资金

c++ - 无法在 COM 端口上正确使用 windows.h ReadFile。 WriteFile 似乎工作正常

c++ - 如何避免阅读文本文件中的评论?

java - 在 Java 中使用正则表达式转义双斜杠

java - 二叉树-如何删除元素; java

php - 在 PHP 中使用 cometd ?

javascript 如何读取本地文件拒绝访问

java - 降低此方法的 boolean 表达式复杂度?

java - jsoup 1.8.2 + android,NoClassDefFoundError : Failed resolution of: Ljava/applet/Applet;