我一直在测试2个不同的PHP库(html2text& htmlpurifier)来将html电子邮件转换为纯文本。问题是他们都没有正确格式化EOL。生成的纯文本通常在同一段落中。
这是我用htmlpurifier的函数:
public class DaemonFolder extends Thread {
@SuppressWarnings("deprecation") // stop();
public static void main(String[] args) {
System.out.println("Pulsar enter para finalizar");
DaemonFolder daemonn= new DaemonFolder();
Scanner finalize= new Scanner(System.in);
finalize.nextLine();
daemonn.stop();
finalize.close();
System.out.println("Programa finalizado!");
}
public DaemonFolder() {
setDaemon(true); // Daemon threads in Java are like a service providers for other threads or objects running in the same process as the daemon thread
start();
}
@Override
public void run() {
while (true) {
try {
sleep(5000);
if (new File("anonymous.txt").exists()){
System.out.println("exists");
//DO SOMETHING
} else {
System.out.println("not exists");
}
} catch (Exception e){
e.printStackTrace();
}
}
}
}
有解决方法吗?还是另一种方法呢?
答案 0 :(得分:1)
也许在通过HTML Purifier之前尝试运行nl2br
?