????????java userЭ??
???????java userЭ???????????????java??д??δ????????????????????????
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import lrapi.lr;
public class Actions {
public int init() throws Throwable
{
return 0;
}//end of init
public int action() throws Throwable
{
int DownLoadSize = 0;
String path = "c:\temp\";  //???????????????·??
String vuid = String.valueOf(lr.get_vuser_id()); //?????????????ID????????????
DownLoadSize = UrlTools.getHttpFileByUrl("http://forum.ubuntu.org.cn/download/file.php?id=129973&sid=78fc8d76767ef49b606595824ceb963d"??vuid??path); //????UrlTools.getHttpFileByUrl()
return 0;
}//end of action
public int end() throws Throwable
{
return 0;
}//end of end }
class UrlTools
{
public static int getHttpFileByUrl(String address??String userid??String path)
{
//???????????????????
URL url;
URLConnection conn = null;
int BUFF_SIZE = 1024;
byte[] buf = new byte[BUFF_SIZE];
int DownLoadSize = 0;
BufferedInputStream bis;
FileOutputStream fos = null;
int size = 0;
try
{
url = new URL(address); //address????????????????????
conn =  url.openConnection();//???url?????????????????
bis = new BufferedInputStream(conn.getInputStream()); //??????????????????????bis???????????
fos = new FileOutputStream(path+""+userid+"test000001"+“.pdf”));//???????·?????????????????????????????в????????????????????? // ·??????????????????????????????????д??????????·??
System.out.println("?????????????С?:" + conn.getContentLength()/1024 + "k");
while((size = bis.read(buf)) != -1)   #?????????buf??Сд??????????????С
{
fos.write(buf??0??size);
DownLoadSize = DownLoadSize+size;
}
bis.close();
fos.close();
System.out.println("???" + userid + "????" + url +"???!");
}catch(MalformedURLException e)
{
System.out.println("?????????:");
e.printStackTrace();
}catch(IOException e)
{
System.out.println("?????????:");
e.printStackTrace();         }
return DownLoadSize/1024;
}
}