package com.al_williams.contenthandlers.application;

import java.io.*;
import java.net.*;

public class x_jstring extends ContentHandler {
    public Object getContent(URLConnection urlc) throws IOException {
	Class [] clist=new Class[1];
	clist[0]=String.class;
	return getContent(urlc,clist);
    }
    public Object getContent(URLConnection urlc, Class [] clist) 
       throws IOException {
	for (int i=0;i<clist.length;i++) {
	    if (clist[i]==InputStream.class) 
		return urlc.getInputStream();
	    if (clist[i]==String.class) {
		StringBuffer rv=new StringBuffer();
		InputStream is=urlc.getInputStream();
		byte [] buffer=new byte[256];
		int len;
		do {
		    len=is.read(buffer,0,buffer.length);
		    if (len!=0)
			rv.append(new String(buffer));
		} while (len==buffer.length);
		return rv.toString();
	    }
	}
	return null;
    }
}


