Java»ñµÃÖ¸¶¨ClassLoaderËù¼ÓÔØµÄÀàÁбí
Ò»Ö±ÏëʵÏÖÏñDriverManagerÄÇÑùµÄgetConnection·½·¨£¬Í¨¹ý´Ë·½·¨¾Í¿ÉÒÔ»ñµÃÁ¬½Ó£¬¶øÇÒ»¹²»ÓÃÖ¸¶¨Driver£¬µ«Ç°ÌáÊÇDriverÒѾͨ¹ýClass.forName()»ònew Driver()½øÐÐÁ˼ÓÔØ¡£½ñÌìÖÕÓÚµÃÒÔʵÏÖ¡£
package quiz;
import java.lang.reflect.Field;
public class ClassLoaderDriver {
/**
* @param args
* @throws NoSuchFieldException
* @throws SecurityException
* @throws IllegalAccessException
* @throws IllegalArgumentException
* @throws ClassNotFoundException
*/
public static void main(String[] args) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver");
Field field = ClassLoader.class.getDeclaredField("classes");
field.setAccessible(true);//ÉèÖøóÉÔ±±äÁ¿Îª¿É·ÃÎÊ
System.out.println(field.get(ClassLoader.getSystemClassLoader()));
}
}
ÕâÑùÒ»À´£¬ÎÒÃǾͿÉÒÔʵÏÖºÍDriverManagerÀàËÆµÄ¹¦ÄÜÁË¡£
Ïà¹ØÎĵµ£º
java ²Ù×÷cookie
----------------------------------------------------------------------------------------------------------------------------------------------------
дÈëcookie
£¼%
String cookieName="Sender";
Cookie cookie=new Cookie(cookieName, "Test_Content");
cookie.setMaxAge(10);
respo ......
JAVAÖ®IOÁ÷(³¬ÏêϸµÄJava.io°üµÄ½éÉÜ!)
Ò».InputºÍOutput
1.stream´ú±íµÄÊÇÈκÎÓÐÄÜÁ¦²ú³öÊý¾ÝµÄÊý¾ÝÔ´£¬»òÊÇÈκÎÓÐÄÜÁ¦½ÓÊÕÊý¾ÝµÄ½ÓÊÕÔ´¡£
ÔÚJavaµÄIOÖУ¬ËùÓеÄstream£¨°üÀ¨InputºÍOut stream£©¶¼°üÀ¨Á½ÖÖÀàÐÍ£º
1.1 ÒÔ×Ö½ÚΪµ¼ÏòµÄstream
ÒÔ×Ö½ÚΪµ¼ÏòµÄstream£¬±íʾÒÔ×Ö½ÚΪµ¥Î»´ÓstreamÖжÁÈ¡»òÍùstreamÖÐдÈëÐÅÏ ......
package com.test;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class TimeTest {
//ÓÃÀ´ ......
RT
package
com.fxt.test;
import
org.apache.commons.mail.EmailException;
import
org.apache.commons.mail.SimpleEmail;
public
class
Mail {
public
static
void
m ......
ÔÚJavaÖÐÓÐÁ½ÖÖ²»Í¬µÄ¶Ô±äÁ¿¸³Öµ·½Ê½£¬Ò»ÖÖÊÇÖ±½Ó½«Ò»¸öÖµ¸³¸ø±äÁ¿¡£ÀýÈ磺
int a = 1;
String s = "abc";
Integer in = 125;
ÁíÍâÒ»ÖÖÊÇ´´½¨Ò»¸ö¶ÔÏ󣬲¢½«Æä¸³¸øÒ»¸ö±äÁ¿¡£ÀýÈ磺
String s = new String("abc")
Integer in = new Integer(125);
Á½ÖÖ·½Ê½µÄ²»Í¬Ö®´¦ÔÚÓÚ£º
µÚÒ»ÖÖ·½Ê½±äÁ¿µÄÖµ´æ´¢ÔÚ¶ÑÕ»ÖУ¬µ±ÏÂÒ» ......