本文介绍了在Java中是否有heredoc替代品(heredoc作为PHP)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于JAVA开发,我需要写一个带有\\\\\\&<>字符串的文件,因为从Java我想写一个PHP文件。如果您无法理解,请查看此示例:
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?>");
这是一个乱码的代码,我想写一个干净的如PHP可以做的,但可以'以Java替代方式查找示例:
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;
?>
推荐答案
不,没有直接 heredoc
Java编程语言中的替代品。
No, there is no direct heredoc
alternative in the Java programming language.
检查此类似。
这篇关于在Java中是否有heredoc替代品(heredoc作为PHP)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!