How to write Content Handler

Hi,
If i want to write a content handler program, where should i start from? Could you please provide a sample program or guideline for me to foolow?

Regards
Cliff Seow

Here is the content handler code which I wrote to handle CSV (Comma Seperated Value) files.
There are two files. The first one is
HandlerFactory_csv.java (instance creation) and the second one is ContentHandler_csv.java (actual implementation) which persists the (lets assume a CSV file submitted to IS thru FTP from a client) CSV file contents into a text file at the server.

This content handler has to be registered with the IS with the content type (can be configured as a pacakge level startup service) before it can be invoked by the IS.

Below is the java code:

HandlerFactory_csv.java

import com.wm.app.b2b.server.ContentHandlerFactory;
import com.wm.app.b2b.server.ContentHandler;

public class HandlerFactory_csv extends ContentHandlerFactory
{

public HandlerFactory_csv()
{
}

public ContentHandler create()
{
    return new ContentHandler_csv();
}

}

ContentHandler_csv.java

import com.wm.app.b2b.server.ContentHandler;
import com.wm.app.b2b.server.InvokeState;
import com.wm.util.Values;
import java.io.*;

public class ContentHandler_csv implements ContentHandler
{

public ContentHandler_csv()
{
}

public String getContentType()
{
    return "text/csv";
}

public Values getInputValues(InputStream inputstream, InvokeState invokestate) throws IOException
{

    Values values = new Values();
    ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
    try
    {
        byte abyte0[] = new byte[4096];
        int i;
        while((i = inputstream.read(abyte0)) != -1)
            bytearrayoutputstream.write(abyte0, 0, i);

        byte abyte1[] = new byte[bytearrayoutputstream.size()];
        abyte1 = bytearrayoutputstream.toByteArray();

        String file = "c:\csvOutFile.txt";
        FileOutputStream fos = new FileOutputStream(new File(file));
        fos.write(abyte1);
    }
    catch(IOException ioexception)
    {
        System.out.println("ContentHandler_csv: Exception occurred while handling input file: " + ioexception);
    }
    finally
    {
        if(bytearrayoutputstream != null)
            try
            {
                bytearrayoutputstream.close();
            }
            catch(IOException _ex)
            {
                System.out.println("ContentHandler_csv: Exception occurred while closing bytearrayoutputstream!" + _ex);
            }
    }
    return values;
}

public void putOutputValues(OutputStream outputstream, Values values, InvokeState invokestate) throws IOException
{
}

}

Let me know if this helped you.
Cheers.

What�s the content handler invoked when I call services using the client API (client.jar)?
How can I set a content-type using the TContext object?

even i have same problem