Java×Ô¶¨ÒåÒì³£Àà
×Ô¶¨ÒåÒì³£ : ²½Öè:
Ò»:´´½¨Ò»¸öÀà¼Ì³ÐÓÚThrowable»òÆä×ÓÀà;
¶þ:Ìí¼Ó¹¹Ôì·½·¨;
Èý:ÔÚÒ»¸ö·½·¨ÖÐʹÓÃthrowÅ׳öÒì³£
ËÄ:ÔÚÁíÒ»¸ö·½·¨Öⶻñ²¢´¦ÀíÒì³£
ʾÀý:
Ò»¡¢ ¼Ì³ÐThrowable Àà
public class MySecondException extends Throwable {
public MySecondException() {
super();
}
public MySecondException(String msg) {
super(msg);
}
public MySecondException(String msg, Throwable cause) {
super(msg, cause);
}
public MySecondException(Throwable cause) {
super(cause);
}
}
¶þ¡¢¼Ì³ÐExceptionÀà
public class MyFirstException extends Exception {
public MyFirstException() {
super();
}
public MyFirstException(String msg) {
super(msg);
}
public MyFirstException(String msg, Throwable cause) {
super(msg, cause);
}
public MyFirstException(Throwable cause) {
super(cause);
}
//×Ô¶¨ÒåÒì³£ÀàµÄÖ÷Òª×÷ÓÃÊÇÇø·ÖÒì³£·¢ÉúµÄλÖ㬵±Óû§Óöµ½Ò쳣ʱ£¬
//¸ù¾ÝÒì³£Ãû¾Í¿ÉÒÔÖªµÀÄÄÀïÓÐÒì³££¬¸ù¾ÝÒì³£ÌáʾÐÅÏ¢½øÐÐÐ޸ġ£
}
Èý¡¢²âÊÔ
/**
* ×Ô¶¨ÒåÒì³£ÀàµÄʹÓÃ
* @author new
*
*/
public class TestMyException {
public static void firstException() throws MyFirstException{
throw new MyFirstException("\"firstException()\" method occurs an exception!");
}
public static void secondException() throws MySecondException{
throw new MySecondException("\"secondException()\" method occurs an exception!");
}
public static void main(String[] args) {
try {
TestMyException.firstException();
TestMyException.secondException();
} catch (MyFirstException e1){
System.out.println("Exception: " + e1.getMessage());
e1.printStackTrace();
} catch (MySecondException e2){
System.out.println("Exception: " + e2.getMessage());
e2.printStackTrace();
}
//µ±Ò»¸ötry¿éºóÃæ¸ú×Ŷà¸öcatch¿éʱ£¬Èç¹û·¢ÉúµÄÒ쳣ƥÅäµÚÒ»¸öcatch¿éµÄ²ÎÊý£¬±ã½«Òì³£´¦ÀíȨÀû½»¸øµÚÒ»¸öcatch¿é¡£
//Èç¹û·¢ÉúµÄÒì³£ÓëµÚÒ»¸öcatch¿é²»Æ¥Å䣬±ã¿´
Ïà¹ØÎĵµ£º
Ç°Ò»¶Îʱ¼ä¸Õ×öÁ˸öjava³ÌÐòºÍÍøÂçÉ϶ą̀»úÆ÷µÄc³ÌÐòͨѶµÄÏîÄ¿£¬×ñѵÄÊÇTCP/IPÐÒ飬Óõ½ÁËjavaµÄSocket±à³Ì¡£ÍøÂçͨѶÊÇjavaµÄÇ¿ÏÓÃTCP/IPÐÒé¿ÉÒÔ·½±ãµÄºÍÍøÂçÉϵÄÆäËû³ÌÐò»¥Í¨ÏûÏ¢¡£
ÏÈÀ´½éÉÜÏÂÍøÂçÐÒ飺
TCP/IP
Transmission Control Proto ......
Èç¹û×Ô¼ºµÄjava projectÖÐÐèÒªÒýÓöîÍâµÄjar°ü×÷Ϊ×ÊÔ´Îļþ£¬ÄÇôÐèÒª×Ô¶¨ÒåÅäÖÃÎļþMANIFEST.MF ,ÀýÈ磺
Manifest-Version: 1.0
Class-Path: lib\crimson.jar lib\jbcl.jar lib\junit.jar lib\log4j-1.2.13.jar lib\mysql-connector-java-3.1.13-bin.jar
Main-Class: src.YourMainClassName
ÆäÖеÄClass-Path¾ÍÖ¸¶¨ÁËÍ ......
×¢£ºwait notify ¶¼ÊÇObjectµÄ·½·¨
ͬ²½£¨×èÈû£© £ºÊÇÒ»ÖÖ·ÀÖ¹¶Ô¹²Ïí×ÊÔ´·ÃÎʵ¼ÖµÄÊý¾Ý²»Ò»ÖµÄÒ»ÖÖģʽ¡£
ÏêϸÇë²Î¿´²Ù×÷ϵͳ¡£
ÔÚJavaÖУ¬ÓÉÓÚ¶Ô¶àÏ̵߳ÄÖ§³Ö£¬¶Ôͬ²½µÄ¿ØÖÆÖ÷Ҫͨ¹ýÒÔϼ¸¸ö·½·¨£¬synchronized£¬ºÍwait(),notify()ºÍnotifyAll(),ÏÂÃæ½øÐÐÒ»Ò»µÄ½²½â£º
A¹Ø¼ü×Ösynchronized
ÿ¸öjava¶Ô ......
Java¶ÁÈ¡PropertiesÎļþµÄÁùÖÖ·½·¨
Java¶ÁÈ¡propertiesÎļþ
ʹÓÃJ2SE API¶ÁÈ¡PropertiesÎļþµÄÁùÖÖ·½·¨
1¡£Ê¹ÓÃjava.util.PropertiesÀàµÄload()·½·¨
ʾÀý£º InputStream in = lnew BufferedInputStream(new FileInputStream(name));
Properties p = new Properties();
p.load(in);
2¡£Ê¹ÓÃjava.util.ResourceBundleÀ ......