我想从文件中读取并写入文件。输入文件如下
<ORLANDO>   <0%>
    As I remember, Adam, it was upon this fashion bequeathed me by will but poor a thousand crowns, and, as thou sayest,
<ORLANDO>
"A s   I   r e m e m b e r    A d a m    i t   w a s   u p o n   t h i s   f a s h i o n   b e q u e a t h e d   m e   b y   w i l l   b u t   p o o r   a   t h o u s a n d   c r o w n s    a n d    a s   t h o u   s a y e s t    c h a r g e d   m y   b r o t h e r   o n  ..."
我编写了一个 java 程序来删除带有标签的行,并用空格替换任何标点符号。但是写出的每个字母之间都有一个空格,并且在行之间也有很多空白行。如何删除它们?. 请帮忙。
String line=null;
    try {
        BufferedReader br=new BufferedReader( new FileReader("filename"));
        PrintWriter writer = new PrintWriter(new FileWriter("filename"));
    try {
            while((line=br.readLine())!=null)
            {
                if(!line.contains("<"))
                {
                    line=(line.replaceAll("\\p{Punct}",""));
                    writer.println(line);
                    writer.flush();
                 }
            }
}