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·´Éä¼¼ÊõÌáÈ¡ÀàÐÅÏ¢
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 ......
JavaµÄ»·¾³±äÁ¿ÅäÖãº
(Á½ÖÖ·½·¨ÈÎÑ¡Ò»ÖÖ½Ô¿É)
·½·¨Ò»£º
ÒÀ´Îµã»÷£º“ÎҵĵçÄÔ”£(ÓÒ¼ü)“ÊôÐÔ”£“¸ß¼¶”£“»·¾³±äÁ¿”£¬µ¯³öWindowsµÄ“»·¾³±äÁ¿”ÅäÖÿ¨¡£
Ôړϵͳ±äÁ¿”À¸ÏÂÖ´ÐÐÈýÏî²Ù×÷£º
¢Ùн¨“Classpath”(Èç¹ûÒÑÓУ¬ÔòÖ±½Ó ......
ÔÎÄÀ´×Ô£ºhttp://gocom.primeton.com/modules/newbb/item44444_44444.htm
1 »ù±¾ÐÅÏ¢
ͻ񻣼
ÏÖÔÚÓкܶàµÄ¹¤¾ß½«Java´úÂë´ò°üΪexeÎļþ£¬Ö´ÐÐʱ²»ÐèÒªÔÙ±àдÅú´¦ÀíÎļþ£¬»òÕßÔÚÃüÁîÐÐÊäÈ볤³¤µÄclasspathÐÅÏ¢£¬ÎªÓû§Ê¹Óà ......