一個完整的Java應用程序
如
package untitled
/**
* This application is to demo how an applcation end
*/
public class Test {
public Test() {}
public static void main(String[] args) {
Test test
//
System
//Do something before system exit
System
}
}
對於簡單的應用系統
然而
對當前應用程序對象的獲得
/*****************************************************************************
本程序僅演示
*****************************************************************************/
package untitled
import java
import java
/**
* This application is used to demo how to hook the event of an application
*/
public class Untitled
public Untitled
doShutDownWork();
}
/***************************************************************************
* This is the right work that will do before the system shutdown
* 這裡為了演示
* 當應用程序退出時候
**************************************************************************/
private void doShutDownWork() {
Runtime
public void run() {
try {
FileWriter fw = new FileWriter(
System
fw
fw
}
catch (IOException ex) {
}
}
});
}
/****************************************************
* 這是程序的入口
***************************************************/
public static void main(String[] args) {
Untitled
long s = System
for (int i =
//在這裡增添您需要處理代碼
}
long se = System
System
}
}
在上述程序中
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19693.html