gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 00:05:13 25 4
gpt4 key购买 nike

<分区>

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com