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 NIO APIÏê½â
ÔÚJDK
1.4ÒÔǰ£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
JavaÓïÑÔ¶¨ÒåÁËpublic¡¢protected¡¢private¡¢abstract¡¢staticºÍfinalÕâ6ÖÖ³£ÓÃÐÞÊδÊÍ⻹¶¨ÒåÁË5¸ö²»Ì«³£ÓõÄÐÞÊδʣ¬ÏÂÃæÊǶÔÕâ11¸öJavaÐÞÊδʵĽéÉÜ£º
1.public
ʹÓöÔÏó£ºÀà¡¢½Ó¿Ú¡¢³ÉÔ±
½éÉÜ£ºÎÞÂÛËüËù´¦Ôڵİü¶¨ÒåÔÚÄÄ£¬¸ÃÀࣨ½Ó¿Ú¡¢³ÉÔ±£©¶¼ÊǿɷÃÎʵÄ
2.private
ʹÓöÔÏ󣺳ÉÔ±
½éÉÜ£º³ÉÔ ......
Îļþ¶ÔÏóµÄÉú³ÉºÍÎļþµÄ´´½¨
/*
* ProcessFileName.java
*
* Created on 2006Äê8ÔÂ22ÈÕ, ÏÂÎç3:10
*
* Îļþ¶ÔÏóµÄÉú³ÉºÍÎļþµÄ´´½¨
*/
package study.iostudy;
import java.io.*;
public class GenerateFile
{
public static void main(String ......
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 ......
/**
* ==ºÅÊDZȽÏÁ½¸ö»ù±¾ÀàÐÍÊÇ·ñÏàµÈ,»òÕ߱ȽÏÁ½¸ö¶ÔÏóÒýÓÃÊÇ·ñÏàͬ
*/
public class T {
public static void main(String[] args) {
Integer i1 = 128;
Integer i2 = 128;
int i3 = 128;
int i4 = 128;
Integer i5 = 127;
Integer i6 = 127; ......