以下是我的自定义函数代码: package com.fr.function; import java.net.URL; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import com.fr.script.AbstractFunction; public class webget extends AbstractFunction { public Object run(Object[] args) { URL url = new URL(args[0].toString()); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String Line=""; while((Line=reader.readLine()) != null){ Line += Line; } reader.close(); return Line; } } 下面这个代码能编译通过,但是无返回值: package com.fr.function; import java.net.URL; import java.io.BufferedReader; import java.io.InputStreamReader; import com.fr.script.AbstractFunction; public class webget extends AbstractFunction { public Object run(Object[] args) { try { URL url = new URL("http://www.baidu.com"); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String Line=""; while((Line=reader.readLine()) != null){ Line += Line; } reader.close(); return Line; } catch(Exception e){ return e.getMessage(); } } } |