sorry, 代码如下:import java.io.File;
import java.io.FileDescriptor;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;public class FilterFileWriter extends FileWriter 
{
private short _tokenCounter = 0;

private StringBuffer _buffer = new StringBuffer();
private String _pattern = "Bioseq-set";
private String _lastAppend = "";

private boolean _doWrite = true;

public void append(CharSequence arg0) throws IOException
{
super.append(arg0);
}

public void write(char[] arg0, int arg1, int arg2) throws IOException
{
super.write(arg0, arg1, arg2);
} public void write(int arg0) throws IOException
{
if( _doWrite )
{
super.write( arg0 );
}

if(_lastAppend.equalsIgnoreCase( _pattern ) && !_doWrite && arg0 == 60 )
{
_doWrite = true;
super.write( arg0 );
_lastAppend = "";
}

} public void write(String arg0, int arg1, int arg2) throws IOException
{
super.write(arg0, arg1, arg2);
}
public void write(char[] arg0) throws IOException
{
//Launcher.getLoggerInstance().info( "Writing array " + arg0[0] );
super.write(arg0);
} public void write(String str) throws IOException
{
if( str.equalsIgnoreCase( _pattern ) )
{
if( _lastAppend.equalsIgnoreCase( "</" ) )
{
_doWrite = false;
_lastAppend = str;
return;
}
}

if( str.equalsIgnoreCase( "</" ) )
{
_lastAppend = str;
return;
}

if( _lastAppend.equalsIgnoreCase( "</" ) )
{
super.write( _lastAppend );
}

if( _doWrite )
{
super.write( str );
}

if( str.trim().length() > 0 )
{
_lastAppend = str;
}
}

public void write( String str, boolean force ) throws Exception
{
if( force )
{
super.write( str );
}
} public FilterFileWriter(File arg0) throws IOException
{
super(arg0);
} public FilterFileWriter(File arg0, boolean arg1) throws IOException
{
super(arg0, arg1);
} public FilterFileWriter(FileDescriptor arg0)
{
super(arg0);
} public FilterFileWriter(String arg0) throws IOException
{
super(arg0);
} public FilterFileWriter(String arg0, boolean arg1) throws IOException
{
super(arg0, arg1);
}

private boolean hasPattern()
{
return _buffer != null && _buffer.toString().indexOf( _pattern ) >= 0;
}}

解决方案 »

  1.   

    不好意思,下面这段本来没有的,是我为了解决这个问题乱加的:
    public void append(CharSequence arg0) throws IOException
    {
           super.append(arg0);
    }
    我这样加:
    public Writer append(CharSequence arg0) throws IOException
    {
    return super.append(arg0);
    }
    还是报错:Type mismatch: cannot convert from Appendable to Writer。
    我查了1.5的API DOC,Writer.append()返回的是Writer啊,怎么变成Appendable了?