Java¶¨Ê±Æ÷
ÔÚÓ¦Óÿª·¢ÖУ¬¾³£ÐèҪһЩÖÜÆÚÐԵIJÙ×÷£¬±ÈÈçÿ5·ÖÖÓÖ´ÐÐijһ²Ù×÷µÈ¡£ÔÚWEBÏîÄ¿ÖпÉÄÜÐèҪÿ¸ôÒ»¶Îʱ¼ä×Ô¶¯Éú³É¾²Ì¬Ò³£¬×Ô¶¯¼ì²âÊÇ·ñÓÐÐÂÓʼþ£¬¶¨Ê±×Ô¶¯±¸·ÝÎļþµÈ²Ù×÷¡£ÕâЩ¶¼¿ÉÒÔͨ¹ý¶¨Ê±Æ÷TimerÀ´½â¾ö¡£
ÕâÀï½öÌṩ¶¨Ê±Æ÷µÄ²¿·Ö·½·¨ºÍ˵Ã÷£¬¾²Ì¬Ò³Éú³ÉµÈ²Ù×÷¶ÁÕß¿ÉÒÔͨ¹ýÏà¹Ø·½·¨×ÔÐнâ¾ö¡£
¡£¡£¡£°Ù¶È¿Õ¼äÌù´úÂë×ÜÊǺÜÈÃÈËÍ·ÌÛ£¬ÅźõĴúÂëÄõ½ÕâÀï¾Í³öÏÖ»ìÂÒ¡£
(1)Timer.schedule(TimerTask task,Date time)°²ÅÅÔÚÖƶ¨µÄʱ¼äÖ´ÐÐÖ¸¶¨µÄÈÎÎñ¡£
(2)Timer.schedule(TimerTask task,Date firstTime ,long period)°²ÅÅÖ¸¶¨µÄÈÎÎñÔÚÖ¸¶¨µÄʱ¼ä¿ªÊ¼½øÐÐÖظ´µÄ¹Ì¶¨ÑÓ³ÙÖ´ÐУ®
(3)Timer.schedule(TimerTask task,long delay)°²ÅÅÔÚÖ¸¶¨ÑÓ³ÙºóÖ´ÐÐÖ¸¶¨µÄÈÎÎñ£®
(4)Timer.schedule(TimerTask task,long delay,long period)°²ÅÅÖ¸¶¨µÄÈÎÎñ´ÓÖ¸¶¨µÄÑÓ³Ùºó¿ªÊ¼½øÐÐÖظ´µÄ¹Ì¶¨ÑÓ³ÙÖ´ÐУ®
(5)Timer.scheduleAtFixedRate(TimerTask task,Date firstTime,long period)°²ÅÅÖ¸¶¨µÄÈÎÎñÔÚÖ¸¶¨µÄʱ¼ä¿ªÊ¼½øÐÐÖظ´µÄ¹Ì¶¨ËÙÂÊÖ´ÐУ®
(6)Timer.scheduleAtFixedRate(TimerTask task,long delay,long period)°²ÅÅÖ¸¶¨µÄÈÎÎñÔÚÖ¸¶¨µÄÑÓ³Ùºó¿ªÊ¼½øÐÐÖظ´µÄ¹Ì¶¨ËÙÂÊÖ´ÐУ®
ϱßдһ¸ö¼òµ¥µÄ²âÊÔÀࣺ
import java.io.IOException;
import java.util.Timer;
public class TimerTest {
public static void main(String[] args){
Timer timer = new Timer();
timer.schedule(new MyTask(), 1000, 2000);//ÔÚ1ÃëºóÖ´ÐдËÈÎÎñ,ÿ´Î¼ä¸ô2Ãë
while(true){//Õâ¸öÊÇÓÃÀ´Í£Ö¹´ËÈÎÎñµÄ,·ñÔò¾Íһֱѻ·Ö´ÐдËÈÎÎñÁË
try {
int ch = System.in.read();
if(ch-'c'==0){
timer.cancel();//ʹÓÃÕâ¸ö·½·¨Í˳öÈÎÎñ
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
static class MyTask extends java.util.TimerTask{
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("ÎÒÊÇÀ´²âÊԵġ£¡£ÎÒÁ½Ãë³öÀ´Ò»´Î");
}
}
}
ÕâÑù£¬Ã¿¸ôÁ½ÃëÖӾͻáÔÚ¿ØÖÆ̨Êä³öÓï¾ä¡£
ϱß˵϶¨Ê±Æ÷ÔÚJSPÖеÄÓ¦Óá£ÔÚJSPÖпÉÒÔ¿¿¼àÌýÆ÷ºÍ¶¨Ê±Æ÷µÄ½áºÏÀ´½â¾öijЩÎÊÌâ¡££¨SpringÌṩ¶¨Ê±Æ÷µÄ¸ß¼¶ÊµÏÖ¶ÁÕß¿ÉÒÔÖ´ÐÐÑо¿£¬ÕâÀïÕâ˵һ¸ö¼òµ¥µÄʵÏÖ¡££©
ÏÈÀ´Ò»¸ö¶¨Ê±Æ÷µÄÈÎÎñ£º
package com.kanba.init;
import java.util.Date;
import java.ut
Ïà¹ØÎĵµ£º
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
import java.lang.reflect.*;
public class ReflectTester {
public Object copy(Object object) throws Exception{
//»ñµÃ¶ÔÏóµÄÀàÐÍ
Class classType=object.getClass();
System.out.println("Class:"+classType.getName());
//ͨ¹ýĬÈϹ¹Ôì·½·¨´´½¨Ò»¸öеĶÔÏó
Object objectCo ......
Java´«µÝ²ÎÊýÓÐÁ½ÖÖ £ºÖµ´«µÝ£¬ÒýÓô«µÝ
Ò»°ãÒýÓÃÀàÐÍ ÊÇÒýÓô«µÝ£¬ÖµÀàÐÍÊÇÖµ´«µÝ
ÖµÀàÐÍÊÇÔʼÊý¾ÝÀàÐÍ °üÀ¨ int,byte,char short long,boolean,float,double
ÒýÓÃÀàÐ;ÍÊÇÒ»°ãµÄclassÀà µ±È»Ò²°üÀ¨ÔʼÊý¾ÝµÄ·â×°ÀàÐÍ ±ÈÈçintµÄ
·â×°ÀàÐÍΪInteger
Ò»°ãÇé¿öÏ£º
Öµ´«µÝ£º
Àý×Ó 1 public void show1(int str ......
E:\>javac -X
-Xlint ÆôÓý¨ÒéµÄ¾¯¸æ
-Xlint:{all,deprecation,unchecked,fallthrough,path,serial,finally,-deprecat ion
,-unchecked,-fallthrough,-path,-serial,-finally}ÆôÓûò½ûÓÃÌض¨µÄ¾¯¸æ
& ......
¿ÉÄÜ´ó¶àÊýJsp¿ª·¢Ô±ÔÚдÍê³ÌÐò²âÊÔͨ¹ýºó£¬²»Ì«»á¹Ø×¢JspÉú³ÉµÄJavaÎļþ£¬Æäʵ£¬Í¨¹ýJava´úÂ룬¸üÄÜÌåÏÖ³ÌÐò´úÂëµÄÕæÕýº¬Ò壬¶Ô½øÒ»²½Ñо¿³ÌÐò´úÂëµÄºǫ́ÔËÐÐÇé¿öÊǷdz£ÓаïÖúµÄ¡£ÀýÈ磬ÓÃJsp±àд´úÂëʱ£¬ÓÐʱºòÓÃ<%! %>£¬ÓÐʱºòÓÃ<% %>£¬¼Ó²»¼Ó¸Ð̾º ......