//静态块(static block):如下所示
public class StaticBlock1
{
static
{
System.out.println("static block");
}
public static void main(String[] args)
{
System.out.println("main");
}
}
/**
静态块是在类被调用到内存后开始执行的,它和创建对象或main方法都没有关系。
如果没有main方法,程序仍然编译成功,但运行错误。
上例中,运行结果为:static block
main
*/
非静态块(non-static block)
public class NonStaticBlock1
{
{ ......
Database
MySQL
PostgreSQL
Firebird(suitable for embedded database)
HSQLDB(160K)
DB Tie
Hibernate
Ibatis
JDO
OSCache
JBossCache
Business Tie
Spring
UI Tie
Structs
JSF
Tapestry
Webwork
Flex
DWR(Ajax
Framework)
ZK(Ajax
Framework)
Dojo(Ajax
Framework)
Development Tools
Eclipse
NetBeans
Web Server
Tomcat
Jetty
App Server
Jboss
Tools
Quartz(job scheduling system)
Velocity(Template Engine)
Roller
Weblogger
(Blog)
Apahce
Lucene
(
full
text searching)
iText
(produce PDF)
JUnit
(Unit Test)
XWiki
Xiss
web(
Web Album)
Portal
Liferay
(J2EE App,Portal
system)
Jetspeed
(Enterprise
Information Portal)
CMS
OpenCms
Webman
dotCMS
WorkFlow
jBpm
Forum
JForum
......
2009-11-11 18:06:09
/**
*
* @author Ice*
*/
public class RarUtil{
public static void main(String args[]) throws Exception {
String compress = "D:\\test.rar";// rar压缩文件
String decompression = "D:\\";// 解压路径
unZip(compress, decompression);
}
/**
* 解压
*
* @param compress
* rar压缩文件
* @param decompression
* 解压路径
*/
public static void unZip(String compress, String decompression) throws Exception {
java.lang.Runtime rt = java.lang.Runtime.getRuntime();
Process p = rt.exec("C:\\Program Files\\WinRAR\\UNRAR.EXE x -o+ -p- " + compress + " " + decompression);
StringBuffer sb = new StringBuffer();
java.io.InputStream fis = p.getInputStream();
int value = 0;
while ((value = fis.read()) != -1)
{
sb.append((char) value);
}
fis.close();
String result = new String(sb.toString().getBytes("ISO-8859-1"), "GBK");
......
java exception 解决方案 - 我的异常网|异常|exception 730 - org.hibernate.LazyInitializationException:could not initialize proxy 731 - 警告: Error setting value 732 - override and commit 733 - Building workspace has encountered a problem. Errors during build 734 - Could not open the editor: An unexpected exception was thrown 735 - Error creating the view.An error occurred while automatically activating bundle org.eclipse.jdt.ui 736 - java.lang.IllegalMonitorStateException 737 - java.lang.UnsupportedClassVersionError: Bad version number in .class file 738 - java.io.EOFException 739 - not allowed to send 740 - 严重: Error listenerStart 741 - 抛异常 742 - ActionContext.getContext().getSession() 报空异常 743 - 为什么程序中有退出的代码java还要抛出异常呢? 744 - java.lang.StringIndexOutOfBoundsException: String index out of range 745 - 严重: Exception starting filter struts2 746 - java.lang.OutOfMemoryError 747 - Exception starting filter struts2 748 - struts2抛自定义异常 749 - ERROR 10 ......
java exception 解决方案 - 我的异常网|异常|exception 730 - org.hibernate.LazyInitializationException:could not initialize proxy 731 - 警告: Error setting value 732 - override and commit 733 - Building workspace has encountered a problem. Errors during build 734 - Could not open the editor: An unexpected exception was thrown 735 - Error creating the view.An error occurred while automatically activating bundle org.eclipse.jdt.ui 736 - java.lang.IllegalMonitorStateException 737 - java.lang.UnsupportedClassVersionError: Bad version number in .class file 738 - java.io.EOFException 739 - not allowed to send 740 - 严重: Error listenerStart 741 - 抛异常 742 - ActionContext.getContext().getSession() 报空异常 743 - 为什么程序中有退出的代码java还要抛出异常呢? 744 - java.lang.StringIndexOutOfBoundsException: String index out of range 745 - 严重: Exception starting filter struts2 746 - java.lang.OutOfMemoryError 747 - Exception starting filter struts2 748 - struts2抛自定义异常 749 - ERROR 10 ......
先看个例子:
接口
package example;
public interface Basic {
public void hello();
}
接口的实现类
package example;
public class BasicService implements Basic {
public void hello() {
Sysytem.out.println("Hello, world");
}
}
实现了InvocationHandler接口的类
package example;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.logging.Level;
import java.util.logging.Logger;
public class LogHandler implements InvocationHandler {
private Logger logger = Logger.getLogger(this.getClass().getName());
private Object delegate;
public Object bind(Object delegate) {
this.delegate = delegate;
return Proxy.newPro ......