是的,我已经阅读了其他一些关于换行的帖子,但他们没有帮助我.
我的Java程序应该读取.PHP文件并将源代码拆分为逐行格式.问题是我似乎无法真正区分一个换行符.
我试图使用/ n没有工作....我试图使用/ r/n没有工作.....
这是一个例子
step_B = step_A.replaceAll("\n", "XXX");
Run Code Online (Sandbox Code Playgroud)
我试图用单词XXX替换换行符,但它没有用.
这里是我想要拆分的php的一个示例,我设法将这些行分开使用; 作为分隔符,但我现在要进一步完善它.
$ALL_AUTH = mysql_fetch_row($author_lookup);
//preparing to display the output in the table
echo "<tr>";
Run Code Online (Sandbox Code Playgroud)
我希望它输出这样的东西
INFO: $ALL_AUTH = mysql_fetch_row($author_lookup)
INFO: //preparing to display the output in the table
INFO: echo "<tr>"
Run Code Online (Sandbox Code Playgroud)
但我得到了这个
INFO: $ALL_AUTH = mysql_fetch_row($author_lookup)
INFO: //preparing to display the output in the table echo "<tr>"
Run Code Online (Sandbox Code Playgroud)
在评论结束于"表格"一词后,应用程序似乎无法检测到有换行符.有没有办法做到这一点 ?最好不用硬编码字表或类似的东西.
哦,我发现了这个错误,我在早期的代码块上使用了一些正则表达式的转换,这搞砸了新行......代码块变成了一个庞大的文本行!因此,没有换行感谢您的时间!
我一直在做一项工作,当我尝试运行它时,我的ide冻结了,我必须使用任务管理器来关闭它.
任何想法为什么?我知道它与迭代器和我正在使用的循环有关
任何人都可以发现它吗?下面是servlet代码的一部分
try {
List<FileItem> fields = upload.parseRequest(request);
Iterator<FileItem> it = fields.iterator();
//starting conversion from file to sample
//creating a container to hold the samples
ArrayList<sample> samplelist = new ArrayList();
while (it.hasNext()) {
sample c = new sample();
FileItem fileItem = it.next();
c.setFileName(fileItem.getName());
c.setPayload(fileItem.getString());
samplelist.add(c);
}
//looping through uploaded samples to split code into lines
for (int i = 0; i < samplelist.size(); i++) {
sample current = new sample();
current = samplelist.get(i);
//splitting whole code block into lines …Run Code Online (Sandbox Code Playgroud)