一段java下载的程序参考
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Properties;
public class Down {
/**
* @param args
*/
private static int downloaded; // number of bytes downloaded
private static final int MAX_BUFFER_SIZE = 1024;
private static int size; // size of download in bytes
public static void main(String[] args) throws Exception{
downloaded = 0;
size=0;
String url = "http://ime.sogou.com/dl/sogou_pinyin_42l.exe";
String proxy = "proxy.zte.com.cn";
String hosturl = url.substring(7, url.indexOf("/", 7));
String requesturl = url.substring(hosturl.length()+7);
//URL url1 = new URL(proxy + requesturl);
URL url1 = new URL(url);
HttpURLConnection connection =
(HttpURLConnection) url1.openConnection();
//connection.setRequest
相关问答:
我目前在本地的linux上写了一个swing的界面,想通过这个界面来控制其它电脑的linux重启。
我知道用Runtime.getRuntime().exec("shutdown -r");可以控制本机Linux重启,但是怎么控制远程的linux重启呢? ......
<%@page language="java" contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="db" class="wang.connectDB"/>
< ......
查API,看到FeatrueFactory有这个方法
public Feature createPolyLine(double[][] thePoints,
R ......
我在eclipse中写了一个播放音乐的类,并把音乐文件和类文件放在了一起,结果运行时,出现错误,说是音乐文件那个是空的,但是在jcreator用同样的方法结果是可以运行的,请求高说指教,告诉为什么?急
你若是在Windo ......
Java正则表达式。
Pattern p2 = Pattern.compile(" <a.*>");
Matcher m2 =p2.matcher(ss);
如何把 类似与 <a href="xxxxx.html">Lakers </a>的标签给替换掉呀? 把 ......