易截截图软件、单文件、免安装、纯绿色、仅160KB

Java从web服务器下载文件到本地

/*从服务器中下载文件到本地*/
/*url:文件存放在服务器的地址;target:要保存的路径*/
 
public String DownloadFile(String url,String target){
URLConnection con=null;
URL theUrl=null;
try {
theUrl=new URL(url);//建立地址
con = theUrl.openConnection();//打开连接
con.setConnectTimeout(30000);
con.connect();//连接
} catch (MalformedURLException e) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);
return "给定的URL地址有误,请查看";
}
catch (IOException e) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);
return "无法连接到远程机器,请重试!";
}
jLabel5.setText("√");
Process++;
File file = new File(gbl_ParentPath+"/UpdateTemp");
if(file.exists()==false){
file.mkdir();
}
String type = con.getContentType();
if (type != null) {
byte[] buffer = new byte[4 * 1024];
int read;
try {
FileOutputStream os = new FileOutputStream(target);
InputStream in = con.getInputStream();//重定向输入
while ((read = in.read(buffer)) > 0) {//读取输出
os.write(buffer, 0, read);//写入本地文件
}
os.close();
in.close();
jLabel6.setText("√");
Process++;
} catch (FileNotFoundException e) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);
return "所要下载的文件不存在!";
}catch (IOException e) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);


相关文档:

*成为Java高手的25个学习要点*

 1. 你需要精通面向对象分析与设计(OOAOOD)、涉及模式(GOF,J2EEDP)以及综合模式。你应该了解UML,尤其是class、object、interaction以及statediagrams.   2. 你需要学习Java语言的基础知识以及它的核心类库(collections、serialization、streams、networking、multithreading、reflection、event、handling、N ......

Java多线程: 生产者消费者问题(源码)

有人反映看不到源码,发现是CSDN的代码控件有问题。希望CSDN好好改进一下。
暂时先以文本方式发布出来,格式会变样。
import java.util.LinkedList;
public class ProducerConsumer
{
 /**
  * @param args
  */
 public static void main(String[] args)
 {
  Queue queue = ......

JAVA专业术语集

 JAVA专业术语集
API:Java ApplicationProgrammingInterface API(应用程序接口)是事先写好的代码,
        组织到相关包。例如 Applet 和 AWT 包包括建立字体、菜单、按钮的类(CLASS),
        全部的Java API被包含在JavaTM 2 Stan ......

JAVA处理日期时间常用方法


Calendar 类是一个抽象类,它为特定瞬间与一组诸如 YEAR、MONTH、DAY_OF_MONTH、HOUR 等 日历字段之间的转换提供了一些方法,并为操作日历字段(例如获得下星期的日期)提供了一些方法。瞬间可用毫秒值来表示,它是距历元(即格林威治标准时间 1970 年 1 月 1 日的 00:00:00.000,格里高利历)的偏移量。
例:
Calenda ......

java 联动

 JSP:javascript 和 struts部分
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td>
<span class="txt1">三级单位:</span>
<html:select property="oilarea" style="width:182" styleId="area" onchange="javascript:fillWell()"&g ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号