Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 Á¬½ÓÊý¾Ý¿â¡¢Ö´ÐÐSQL·â×°Àà

/*µ±Ö´ÐÐSQLʱ·¢ÏÖ²»ÄÜÁ¬½ÓÊý¾Ý¿â£¬ÏÈÖØÁ¬Ò»´Î*/
 
import java.io.FileInputStream;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
......

Java¶àÏß³Ì: Éú²úÕßÏû·ÑÕßÎÊÌâ(Ô´Âë)

ÓÐÈË·´Ó³¿´²»µ½Ô´Â룬·¢ÏÖÊÇCSDNµÄ´úÂë¿Ø¼þÓÐÎÊÌ⡣ϣÍûCSDNºÃºÃ¸Ä½øһϡ£
ÔÝʱÏÈÒÔÎı¾·½Ê½·¢²¼³öÀ´£¬¸ñʽ»á±äÑù¡£
import java.util.LinkedList;
public class ProducerConsumer
{
 /**
  * @param args
  */
 public static void main(String[] args)
 {
  Queue queue = ......

javaÎļþ·ÃÎÊFileÀ༰Æä¹ýÂË

import java.io.*;
class FileTest
{
 public static void main(String[] args) throws Exception
 {
  //File f=new File("1.txt");
  //f.createNewFile();
  //f.mkdir();
  //File f=new File("E:\\JavaLesson\\Lesson7\\1.txt");//ÔÚWindowsϵͳÏÂ,Óþø¶Ô ......

javaÀàÐÍѧϰ


Ò»¸öjavaÎļþÖУ¬ÓÐÇÒÖ»ÓÐÒ»¸öpublicÀà
float ff= 1.3f;(4B)
int 4B;
long 8B;
double 8B;
byte Ò»×Ö½ÚÕûÐÍ
char 2B
Êý×é
int num[] = new int[3];
int[] num;
num = new int[3];
int [] num = new int[]{1,2,3};
int [][] num;
num = new int[3][4];
//²»Í¬³¤
num = new int[3][];
num[0] = new int[5]; ......

Java¶àÏ̱߳à³ÌÏê½â

Ò»£ºÀí½â¶àÏß³Ì
¶àÏß³ÌÊÇÕâÑùÒ»ÖÖ»úÖÆ£¬ËüÔÊÐíÔÚ³ÌÐòÖв¢·¢Ö´Ðжà¸öÖ¸ÁîÁ÷£¬Ã¿¸öÖ¸ÁîÁ÷¶¼³ÆΪһ¸öỊ̈߳¬±Ë´Ë¼ä»¥Ïà¶ÀÁ¢¡£
Ïß³ÌÓÖ³ÆΪÇáÁ¿¼¶½ø³Ì£¬ËüºÍ½ø³ÌÒ»ÑùÓµÓжÀÁ¢µÄÖ´ÐпØÖÆ£¬ÓɲÙ×÷ϵͳ¸ºÔðµ÷¶È£¬Çø±ðÔÚÓÚÏß³ÌûÓжÀÁ¢µÄ´æ´¢¿Õ¼ä£¬¶øÊǺÍËùÊô½ø³ÌÖеÄÆäËüÏ̹߳²ÏíÒ»¸ö´æ´¢¿Õ¼ä£¬ÕâʹµÃÏ̼߳äµÄͨÐÅÔ¶½Ï½ø³Ì¼òµ¥¡£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ