public static Scriptable jsFunction_writeTo(Context cx, Scriptable thisObj,
Object[] arguments, Function funObj) throws ScriptException {
FeedHostObject feedObject = (FeedHostObject) thisObj;
FileHostObject fileHostObject;
OutputStreamWriter outputStreamWriter = null;
try {
if (arguments[0] instanceof String) {
fileHostObject = (FileHostObject) cx.newObject(feedObject,
"File", arguments);
outputStreamWriter = new OutputStreamWriter(
fileHostObject.getOutputStream());
feedObject.feed.writeTo(outputStreamWriter);
outputStreamWriter.flush();
} else if (arguments[0] instanceof FileHostObject) {
fileHostObject = (FileHostObject) arguments[0];
outputStreamWriter = new OutputStreamWriter(
fileHostObject.getOutputStream());
feedObject.feed.writeTo(outputStreamWriter);
outputStreamWriter.flush();
} else {
throw new ScriptException("Invalid parameter");
}