java 将服务器端的文件 下载到 客服端 指定目录下?
程序代码:
public void down() throws MalformedURLException, IOException{
InetAddress addr = InetAddress.getLocalHost();
String ip = addr.getHostAddress().toString();// 获得本机IP
//String port = request.getLocalPort();
System.out.println(ip);
String filepath = "C:/WINDOWS/system32/bb.dll";
File f = new File(filepath);
if(f.exists()){
System.out.println("------bb已存在");
}else{
InputStream ios = new URL("http://"+ip+":8080/project/bb/bb.dll").openConnection().getInputStream();
BufferedOutputStream bout=new BufferedOutputStream(new FileOutputStream("C:/WINDOWS/system32"));
byte buff[]=new byte[1024];
int count;
while((count=ios.read(buff))>0){
bout.write(buff, 0, count);
}
ios.close();
bout.close();
}
InetAddress addr = InetAddress.getLocalHost();
String ip = addr.getHostAddress().toString();// 获得本机IP
//String port = request.getLocalPort();
System.out.println(ip);
String filepath = "C:/WINDOWS/system32/bb.dll";
File f = new File(filepath);
if(f.exists()){
System.out.println("------bb已存在");
}else{
InputStream ios = new URL("http://"+ip+":8080/project/bb/bb.dll").openConnection().getInputStream();
BufferedOutputStream bout=new BufferedOutputStream(new FileOutputStream("C:/WINDOWS/system32"));
byte buff[]=new byte[1024];
int count;
while((count=ios.read(buff))>0){
bout.write(buff, 0, count);
}
ios.close();
bout.close();
}
这个 下载 还是在 服务器上,怎么修改一下,把他 下载到 客服端 指定目录("C:/WINDOWS/system32")下呢?
新手 ,请会的赐教啊。因为 急 所以就直接来问了,不是我不爱思考啊 ,哈哈。
搜索更多相关主题的帖子:
java 服务器 客服 目录 文件
----------------解决方案--------------------------------------------------------