JAVAÐòÁл¯µÄÁ½ÖÖ·½Ê½¡¾×ªÌù¡¿
JAVAÐòÁл¯µÄÁ½ÖÖ·½Ê½
//´ó¼Ò¶¼ÖªµÀSerializableÊÇÒ»¸ömark interface,¸æËßJVMÕâ¸ö¶ÔÏó¿ÉÒÔ±»×ª»»³É¶þ½øÖÆÁ÷À´´«Êä.
//Serializable ÔÚÎÒÃÇʵÏÖÕâ¸ö½Ó¿ÚµÄʱºò,ÎÒÃÇ¿ÉÒÔʹÓÃ4¸ö˽Óз½·¨À´¿ØÖÆÐòÁл¯µÄ¹ý³Ì:
//ÎÒÃÇÀ´¿´Ò»¸öÀý×Ó:
public class FooImpl implements java.io.Serializable
{
private String message;
public String getFoo()
{
return message;
}
public void setMessage( String message )
{
this.message = message;
}
private void writeObject( java.io.ObjectOutputStream out ) throws IOException
{
System.out.println( "writeObject invoked" );
out.writeObject( this.message == null ? "hohohahaha" : this.message );
}
private void readObject( java.io.ObjectInputStream in ) throws IOException, ClassNotFoundException
{
System.out.println( "readObject invoked" );
this.message = (String) in.readObject();
}
private Object writeReplace() throws ObjectStreamException
{
System.out.println( "writeReplace invoked" );
return this;
}
private Object readResolve() throws ObjectStreamException
{
System.out.println( "readResolve invoked" );
return this;
}
public Object serialize() throws IOException, ClassNotFoundException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( baos );
oos.writeObject( this );
ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() );
ObjectInputStream ois = new ObjectInputStream( bais );
return ois.readObject();
}
public static void main(String[] args) throws IOException, ClassNotFoundException
{
FooImpl fooimpl = new FooImpl();
fooimpl.se
Ïà¹ØÎĵµ£º
ÓÐЩʱºò,ÎÒÃÇÏëÔÚµ±Ç°µÄÈÕÆÚÉϼӼ¸Ìì¡¢¼¸¸öÔ£¬»ò¼¸Ä꣬ʹÓÃjava.util.Date£¬È´×ÜÒ²ÕÒ²»µ½ºÏÊʵķ½·¨£¬ÎÞÄÎ֮ϣ¬ÇëÒ»¸ö¸ßÈ˰ïæ£¬ÀÏÁõ¸øÁËÒ»¾ä»°£ºÊ¹ÓÃCanlender¡£Ö®ºó£¬ÎÒ¾ÍʹÓÃCalender£¬Ò»Ó㬻¹ÕæºÃÓ㬾Íд³öÀ´£¬ºÍ´ó¼Ò¹²Í¬·ÖÏí£º
² ÎÒµÄÐèÇó
ÎÒÔÚ×÷Ò»¸öµ÷²éÎÊ¾í£¬ÏëÉ趨ÎʾíµÄÓÐЧÌìÊý£ºÔÚ·¢²¼Ö ......
ÀûÓÃjava·´Éä¼¼ÊõÌáÈ¡ÀàÐÅÏ¢
1 package day15;
2
3 import java.lang.reflect.*;
4
5 public class ReflectionTest {
6
7 public& ......
ÔÚjava¿ª·¢µÄÔçÆÚ£¬Öص㱻·ÅÔÚÁ˿ͻ§¶Ë¿ª·¢¡£ÓïÑÔÖжÔÓÚappletºÍ°²È«ÏÂÔØµÄÖ§³Ö
¶ÔÓÚÍòÎ¬Íø£¨WWW£©µÄ·¢²¼¿´ÉÏÈ¥ÊǸö²»´íµÄÖ÷Òâ¡£µ«ÊÇÏÖʵÊÇjava×î´óµÄ³É¹¦ÔÚÓÚ·þÎñÆ÷¶Ë£¬javaµÄÇ¿´ó¹¦ÄܺÍÊÊÓ¦ÐÔÓ®µÃÁË·þÎñÆ÷¶Ë¿ª·¢ÕßµÄÐÄ¡£Í¬Ê±£¬¿Í»§¶ËµÄ¿ª·¢ÂäºóÁË¡£¼¬ÊֵĿª·¢ÎÊÌâÏÞÖÆÁËappletµÄЧÓ㬿ª·¢Õß±»ÆÈתÏò»ùÓÚä¯ÀÀÆ÷µÄÊݿͻ§¶ ......
public class FilePath {
public void Print() {
String a = this.getClass().getClassLoader().getResource(".").getPath();
String b = this.getClass().getResource("").getPath();
String c = this.getClass().getResource(" ").getPath();
&n ......
Óà Groovy ±àд¸üÉٵĴúÂ룬Íê³É¸ü¶àµÄ¹¤×÷
¼¶±ð£º ³õ¼¶
Scott Davis , ´´Ê¼ÈË, ThirstyHead.com
2009 Äê 3 ÔÂ 09 ÈÕ
Groovy ר¼Ò Scott Davis ½«ÖØÐ¿ªÊ¼×«Ð´ ʵս Groovy ϵÁÐÎÄÕ£¬¸ÃϵÁÐÎÄÕÂÓÚ 2006 ÄêÍ£Ö¹±àд¡£×÷Ϊ¿ªÆªÎÄÕ£¬±¾ÎĽ«½éÉÜ Groovy ×î½üµÄ·¢Õ¹ÒÔ¼° Groovy µ±Ç°µÄ״̬¡£È»ºóÁ˽ⴠ......