ï»??xml version="1.0" encoding="utf-8" standalone="yes"?>一区二区久久久久,成人欧美一区二区三区黑人麻豆 ,四虎影视精品http://www.aygfsteel.com/hayun/category/16892.htmlwelcome to my online log ! open java new world! Taste java charm........zh-cnThu, 01 Mar 2007 19:07:18 GMTThu, 01 Mar 2007 19:07:18 GMT60java基础学习16(java.io.DataOutputStream)http://www.aygfsteel.com/hayun/articles/java16.htmlè‹?/dc:creator>è‹?/author>Sun, 12 Nov 2006 15:21:00 GMThttp://www.aygfsteel.com/hayun/articles/java16.html import  java.io.DataOutputStream;
import  java.io.FileOutputStream;

public class  MainClass  {

   public static  void  main ( String args []) {
     try  {

       FileOutputStream fos =  new  FileOutputStream ("fileName" ) ;

       DataOutputStream dos =  new  DataOutputStream ( fos ) ;

       dos.writeBoolean ( false ) ;
       dos.writeByte ( Byte.MAX_VALUE ) ;
       dos.writeChar ( 'A' ) ;
       dos.writeDouble ( Double.MAX_VALUE ) ;
       dos.writeFloat ( Float.MAX_VALUE ) ;
       dos.writeInt ( Integer.MAX_VALUE ) ;
       dos.writeLong ( Long.MAX_VALUE ) ;
       dos.writeShort ( Short.MAX_VALUE ) ;

       fos.close () ;
     }  catch  ( Exception e ) {
       System.out.println ( "Exception: "  + e ) ;
     }
   }
}  

]]>
java基础学习15(java.io.DataInputStream)http://www.aygfsteel.com/hayun/articles/java15.html�/dc:creator>�/author>Sun, 12 Nov 2006 15:19:00 GMThttp://www.aygfsteel.com/hayun/articles/java15.html import  java.io.DataInputStream;
import  java.io.FileInputStream;

public class  MainClass  {

   public static  void  main ( String args []) {
     try  {

       FileInputStream fis =  new  FileInputStream ( "fileName.dat" ) ;

       // Create a data input stream
       DataInputStream dis =  new  DataInputStream ( fis ) ;

       // Read and display data
       System.out.println ( dis.readBoolean ()) ;
       System.out.println ( dis.readByte ()) ;
       System.out.println ( dis.readChar ()) ;
       System.out.println ( dis.readDouble ()) ;
       System.out.println ( dis.readFloat ()) ;
       System.out.println ( dis.readInt ()) ;
       System.out.println ( dis.readLong ()) ;
       System.out.println ( dis.readShort ()) ;

       // Close file input stream
       fis.close () ;
     }  catch  ( Exception e ) {
       System.out.println ( "Exception: "  + e ) ;
     }
   }
}

]]>
java基础学习14(java.io.File)http://www.aygfsteel.com/hayun/articles/java14.html�/dc:creator>�/author>Sun, 12 Nov 2006 15:17:00 GMThttp://www.aygfsteel.com/hayun/articles/java14.html import  java.io.File;

public class  MainClass  {
     public static  void  main ( String args []) {
   File f1 =  new  File ( "MainClass.java" ) ;
   System.out.println ( "File Name:"  + f1.getName ()) ;
   System.out.println ( "Path:"  + f1.getPath ()) ;
   System.out.println ( "Abs Path:"  + f1.getAbsolutePath ()) ;
   System.out.println ( "Parent:"  + f1.getParent ()) ;
   System.out.println ( f1.exists ()  ?  "exists"  :  "does not exist" ) ;
   System.out.println ( f1.canWrite ()  ?  "is writeable"  :  "is not writeable" ) ;
   System.out.println ( f1.canRead ()  ?  "is readable"  :  "is not readable" ) ;
   System.out.println ( "is a directory"  + f1.isDirectory () ) ;
   System.out.println ( f1.isFile ()  ?  "is normal file"  :  "might be a named pipe" ) ;
   System.out.println ( f1.isAbsolute ()  ?  "is absolute"  :  "is not absolute" ) ;
   System.out.println ( "File last modified:"  + f1.lastModified ()) ;
   System.out.println ( "File size:"  + f1.length ()  +  " Bytes" ) ;
     }
}

]]>
java基础学习13(java.io.BufferedOutputStream)http://www.aygfsteel.com/hayun/articles/java13.html�/dc:creator>�/author>Sun, 12 Nov 2006 15:14:00 GMThttp://www.aygfsteel.com/hayun/articles/java13.html import  java.io.BufferedOutputStream;
import  java.io.FileOutputStream;

public class  MainClass  {

   public static  void  main ( String args []) {

     try  {

       FileOutputStream fos =  new  FileOutputStream ("fileName" ) ;

       BufferedOutputStream bos =  new  BufferedOutputStream ( fos ) ;

       for  ( int  i =  0 ; i <  12 ; i++ ) {
         bos.write ( i ) ;
       }

       bos.close () ;
     }  catch  ( Exception e ) {
       System.out.println ( "Exception: "  + e ) ;
     }
   }
}


]]>
java基础学习12(java.io.BufferedInputStream)http://www.aygfsteel.com/hayun/articles/java12.html�/dc:creator>�/author>Sun, 12 Nov 2006 15:11:00 GMThttp://www.aygfsteel.com/hayun/articles/java12.html import  java.io.BufferedInputStream;
import  java.io.FileInputStream;

public class  MainClass  {

   public static  void  main ( String args []) {
     try  {
       FileInputStream fis =  new  FileInputStream ("fileName" ) ;

       BufferedInputStream bis =  new  BufferedInputStream ( fis ) ;

       int  i;
       while  (( i = bis.read ())  != - 1 ) {
         System.out.println ( i ) ;
       }
       fis.close () ;
     }  catch  ( Exception e ) {
       System.out.println ( "Exception: "  + e ) ;
     }
   }
}

]]>
java基础学习11(java.util.Iterator)http://www.aygfsteel.com/hayun/articles/java11.html�/dc:creator>�/author>Sun, 12 Nov 2006 15:07:00 GMThttp://www.aygfsteel.com/hayun/articles/java11.html import  java.util.ArrayList;
import  java.util.Iterator;
import  java.util.ListIterator;

public class  MainClass  {
   public static  void  main ( String args []) {
     ArrayList<String> al =  new  ArrayList<String> () ;

     al.add ( "C" ) ;
     al.add ( "A" ) ;
     al.add ( "E" ) ;
     al.add ( "B" ) ;
     al.add ( "D" ) ;
     al.add ( "F" ) ;

     System.out.print ( "Original contents of al: " ) ;
     Iterator<String> itr = al.iterator () ;
     while  ( itr.hasNext ()) {
       String element = itr.next () ;
       System.out.print ( element +  " " ) ;
     }
     System.out.println () ;

     ListIterator<String> litr = al.listIterator () ;
     while  ( litr.hasNext ()) {
       String element = litr.next () ;
       litr.set ( element +  "+" ) ;
     }

     // Now, display the list backwards.
     System.out.print ( "Modified list backwards: " ) ;
     while  ( litr.hasPrevious ()) {
       String element = litr.previous () ;
       System.out.print ( element +  " " ) ;
     }
   }
}


]]>
java基础学习10(java.util.properties)http://www.aygfsteel.com/hayun/articles/java10.html�/dc:creator>�/author>Sun, 12 Nov 2006 15:03:00 GMThttp://www.aygfsteel.com/hayun/articles/java10.html import  java.util.Properties;

public class  MainClass  {
     public static  void  main ( String args []) {
         Properties prop =  new  Properties () ;
         prop.put ( "a" ,  "1" ) ;
         prop.put ( "b" ,  "2" ) ;
         prop.put ( "c" ,  "3" ) ;
         Properties book =  new  Properties ( prop ) ;
         book.put ( "A" ,  "4" ) ;
         book.put ( "B" ,  "5" ) ;
        
         System.out.println ( "a "  + book.getProperty ( "a" )) ;
         System.out.println ( "A "  + book.getProperty ( "b" )) ;
         System.out.println ( "c: "  + book.getProperty ( "c" )) ;

         System.out.println ( "z: "  + book.getProperty ( "z" ,  "default" )) ;
     }
}

]]>
java基础学习9(java.util.Vector)http://www.aygfsteel.com/hayun/articles/java9.html�/dc:creator>�/author>Sun, 12 Nov 2006 15:02:00 GMThttp://www.aygfsteel.com/hayun/articles/java9.html import  java.util.Vector;

public class  MainClass  {
   public static  void  main ( String args []) {

     // initial size is 3, increment is 2
     Vector<Integer> v =  new  Vector<Integer> ( 3 ,  2 ) ;

     System.out.println ( "Initial size: "  + v.size ()) ;
     System.out.println ( "Initial capacity: "  + v.capacity ()) ;

     v.addElement ( 1 ) ;
     v.addElement ( 2 ) ;

     System.out.println ( "First element: "  + v.firstElement ()) ;
     System.out.println ( "Last element: "  + v.lastElement ()) ;

     if  ( v.contains ( 3 ))
       System.out.println ( "Vector contains 3." ) ;
   }
}


]]>
java基础学习8(java.util.Hashtable)http://www.aygfsteel.com/hayun/articles/false8.html�/dc:creator>�/author>Sun, 05 Nov 2006 09:59:00 GMThttp://www.aygfsteel.com/hayun/articles/false8.html import  java.util.Hashtable;
import  java.util.Iterator;
import  java.util.Set;

public class  MainClass  {
   public static  void  main ( String args []) {
     Hashtable<String, Double> balance =  new  Hashtable<String, Double> () ;

     String str;
     double  bal;

     balance.put ( "A" ,  4.34 ) ;
     balance.put ( "B" ,  3.22 ) ;
     balance.put ( "C" ,  8.00 ) ;
     balance.put ( "D" ,  9.22 ) ;
     balance.put ( "E" , - 9.08 ) ;

     Set<String> set = balance.keySet () ;

     Iterator<String> itr = set.iterator () ;
     while  ( itr.hasNext ()) {
       str = itr.next () ;
       System.out.println ( str +  ": "  + balance.get ( str )) ;
     }

     System.out.println () ;

     bal = balance.get ( "A" ) ;
     balance.put ( "A" , bal +  1000 ) ;
     System.out.println ( "A's new balance: "  + balance.get ( "A" )) ;
   }
}



]]>
java基础学习7(java.util.Enumeration)http://www.aygfsteel.com/hayun/articles/false7.html�/dc:creator>�/author>Sun, 05 Nov 2006 09:57:00 GMThttp://www.aygfsteel.com/hayun/articles/false7.html import  java.util.Enumeration;

class  collection  implements  Enumeration  {
   private  int  count =  0 ;

   private  boolean  more =  true ;

   public  boolean  hasMoreElements () {
     return  more;
   }

   public  Object nextElement () {
     count++;
     if  ( count >  4 )
       more =  false ;
     return new  Integer ( count ) ;
   }
}

public class  MainClass  {
   public static  void  main ( String args []) {
     Enumeration e =  new  collection () ;
     while  ( e.hasMoreElements ()) {
       System.out.println ( e.nextElement ()) ;
     }
   }
}


]]>
java基础学习6(java.util.Date)http://www.aygfsteel.com/hayun/articles/false6.html�/dc:creator>�/author>Sun, 05 Nov 2006 09:56:00 GMThttp://www.aygfsteel.com/hayun/articles/false6.html import  java.text.DateFormat;
import  java.text.SimpleDateFormat;
import  java.util.Date;

public class  MainClass  {

   public static  void  main ( String []  a )  throws  Exception {

     DateFormat df =  new  SimpleDateFormat  ( "yyyy-MM-dd" ) ;

     Date d1 = df.parse ( "2001-01-01" ) ;

     Date d2 = df.parse ( "2000-01-01" ) ;

     String relation;
     if  ( d1.equals ( d2 ))
       relation =  "the same date as" ;
     else if  ( d1.before ( d2 ))
       relation =  "before" ;
     else if  ( d1.after ( d2 ))
       relation =  "after" ;
     System.out.println ( d1 +  " is "  + relation +  ' '  + d2 ) ;
   }
}


]]>
java基础学习5(java.util.Collections)http://www.aygfsteel.com/hayun/articles/false5.html�/dc:creator>�/author>Sun, 05 Nov 2006 09:54:00 GMThttp://www.aygfsteel.com/hayun/articles/false5.html import  java.util.Collections;
import  java.util.Comparator;
import  java.util.LinkedList;
  
public class  MainClass  {
   public static  void  main ( String args []) {  
     LinkedList<Integer> ll =  new  LinkedList<Integer> () ;  
     ll.add ( - 8 ) ;  
     ll.add ( 20 ) ;  
     ll.add ( - 20 ) ;  
     ll.add ( 8 ) ;  

     Comparator<Integer> r = Collections.reverseOrder () ;  

     Collections.sort ( ll, r ) ;  
  
     System.out.print ( "List sorted in reverse: " ) ;      
     for ( int  i : ll ){
       System.out.print ( i+  " " ) ;
     } 
        
     System.out.println () ;  
  
     Collections.shuffle ( ll ) ;  
  
     System.out.print ( "List shuffled: " ) ;      
     for ( int  i : ll ) 
       System.out.print ( i +  " " ) ;  
 
     System.out.println () ;  
  
     System.out.println ( "Minimum: "  + Collections.min ( ll )) ;      
     System.out.println ( "Maximum: "  + Collections.max ( ll )) ;          
   }  
}



]]>
java基础学习4(java.util.Calendar)http://www.aygfsteel.com/hayun/articles/false4.html�/dc:creator>�/author>Sun, 05 Nov 2006 09:52:00 GMThttp://www.aygfsteel.com/hayun/articles/false4.html import  java.util.Calendar;

public class  MainClass  {
   public static  void  main ( String args []) {
     String months []  =  {  "Jan" ,  "Feb" ,  "Mar" ,  "Apr" ,  "May" ,  "Jun" ,  "Jul" ,  "Aug" ,
         "Sep" ,  "Oct" ,  "Nov" ,  "Dec"  } ;

     Calendar calendar = Calendar.getInstance () ;

     System.out.print ( "Date: " ) ;
     System.out.print ( months [ calendar.get ( Calendar.MONTH )]) ;
     System.out.print ( " "  + calendar.get ( Calendar.DATE )  +  " " ) ;
     System.out.println ( calendar.get ( Calendar.YEAR )) ;

     System.out.print ( "Time: " ) ;
     System.out.print ( calendar.get ( Calendar.HOUR )  +  ":" ) ;
     System.out.print ( calendar.get ( Calendar.MINUTE )  +  ":" ) ;
     System.out.println ( calendar.get ( Calendar.SECOND )) ;

     calendar.set ( Calendar.HOUR,  10 ) ;
     calendar.set ( Calendar.MINUTE,  29 ) ;
     calendar.set ( Calendar.SECOND,  22 ) ;

     System.out.print ( "Updated time: " ) ;
     System.out.print ( calendar.get ( Calendar.HOUR )  +  ":" ) ;
     System.out.print ( calendar.get ( Calendar.MINUTE )  +  ":" ) ;
     System.out.println ( calendar.get ( Calendar.SECOND )) ;
   }
}


]]>
java基础学习2(java.util.ArrayList)http://www.aygfsteel.com/hayun/articles/false3.html�/dc:creator>�/author>Sun, 05 Nov 2006 09:50:00 GMThttp://www.aygfsteel.com/hayun/articles/false3.html import  java.util.ArrayList;
import  java.util.Iterator;
import  java.util.ListIterator;

public class  MainClass  {
   public static  void  main ( String args []) {
     ArrayList<String> al =  new  ArrayList<String> () ;

     al.add ( "C" ) ;
     al.add ( "A" ) ;
     al.add ( "E" ) ;
     al.add ( "B" ) ;
     al.add ( "D" ) ;
     al.add ( "F" ) ;

     System.out.print ( "Original contents of al: " ) ;
     Iterator<String> itr = al.iterator () ;
     while  ( itr.hasNext ()) {
       String element = itr.next () ;
       System.out.print ( element +  " " ) ;
     }
     System.out.println () ;

     ListIterator<String> litr = al.listIterator () ;
     while  ( litr.hasNext ()) {
       String element = litr.next () ;
       litr.set ( element +  "+" ) ;
     }

     // Now, display the list backwards.
     System.out.print ( "Modified list backwards: " ) ;
     while  ( litr.hasPrevious ()) {
       String element = litr.previous () ;
       System.out.print ( element +  " " ) ;
     }
   }


]]>
java基础学习1(java.util.AbstractSet)http://www.aygfsteel.com/hayun/articles/false2.html�/dc:creator>�/author>Sun, 05 Nov 2006 09:47:00 GMThttp://www.aygfsteel.com/hayun/articles/false2.html import  java.io.Serializable;
import  java.util.AbstractSet;
import  java.util.ArrayList;
import  java.util.Collection;
import  java.util.Iterator;
import  java.util.Set;

public class  MainClass  {
   public static  void  main ( String args []) {
     Set map =  new  ArraySet () ;
     map.add ( "V" ) ;
     map.add ( "M" ) ;
     map.add ( "N" ) ;
     System.out.println ( map ) ;
   }
}

class  ArraySet  extends  AbstractSet  implements  Cloneable, Serializable  {

   private  ArrayList list;

   public  ArraySet () {
     list =  new  ArrayList () ;
   }

   public  ArraySet ( Collection col ) {
     list =  new  ArrayList () ;

     // No need to check for dups if col is a set
     Iterator itor = col.iterator () ;
     if  ( col  instanceof  Set ) {
       while  ( itor.hasNext ()) {
         list.add ( itor.next ()) ;
       }
     }  else  {
       while  ( itor.hasNext ()) {
         add ( itor.next ()) ;
       }
     }
   }

   public  Iterator iterator () {
     return  list.iterator () ;
   }

   public  int  size () {
     return  list.size () ;
   }

   public  boolean  add ( Object element ) {
     boolean  modified;
     if  ( modified = !list.contains ( element )) {
       list.add ( element ) ;
     }
     return  modified;
   }

   public  boolean  remove ( Object element ) {
     return  list.remove ( element ) ;
   }

   public  boolean  isEmpty () {
     return  list.isEmpty () ;
   }

   public  boolean  contains ( Object element ) {
     return  list.contains ( element ) ;
   }

   public  void  clear () {
     list.clear () ;
   }

   public  Object clone () {
     try  {
       ArraySet newSet =  ( ArraySet )  super .clone () ;
       newSet.list =  ( ArrayList )  list.clone () ;
       return  newSet;
     }  catch  ( CloneNotSupportedException e ) {
       throw new  InternalError () ;
     }
   }
}


]]>
java基础学习3(java.util.Map)http://www.aygfsteel.com/hayun/articles/false1.html�/dc:creator>�/author>Sun, 05 Nov 2006 09:44:00 GMThttp://www.aygfsteel.com/hayun/articles/false1.html import  java.util.HashMap;
import  java.util.Iterator;
import  java.util.Map;

public class  MainClass  {

   public static  void  main ( String []  argv ) {
     Map map =  new  HashMap () ;

     map.put ( "Adobe" ,  "Mountain View, CA" ) ;
     map.put ( "IBM" ,  "White Plains, NY" ) ;
     map.put ( "Learning Tree" ,  "Los Angeles, CA" ) ;

     Iterator k = map.keySet () .iterator () ;
     while  ( k.hasNext ()) {
       String key =  ( String )  k.next () ;
       System.out.println ( "Key "  + key +  "; Value "  +  ( String )  map.get ( key )) ;
     }
   }
}


]]>
Ö÷Õ¾Ö©Öë³ØÄ£°å£º »³ÈÊÏØ| ¹âÉ½ÏØ| Ì©ºÍÏØ| ÌØ¿ËË¹ÏØ| ÎÚ³ľÆëÏØ| ÏóÖÝÏØ| ¿Ëʲ¿ËÌÚÆì| Í©Â®ÏØ| Ïç³ÇÏØ| ƽ¹ûÏØ| ³¤ÄþÇø| ¸£ÈªÊÐ| ÍþÄþ| ¦·³ÏØ| µ±Í¿ÏØ| ºÓ³ØÊÐ| ÖêÖÞÏØ| º£·áÏØ| ɳƺ°ÓÇø| Ïâ»ÆÆì| ¹ãÆ½ÏØ| °Í³þÏØ| ¼ªÂ¡ÏØ| ÐÂÄþÏØ| ľÀ¼ÏØ| ʯºÓ×ÓÊÐ| ÂÔÑôÏØ| ºþÄÏÊ¡| ÎÂÈªÏØ| ÑĮ̀ÊÐ| ¶¼ÔÈÊÐ| ³Â°Í¶û»¢Æì| »ôÖÝÊÐ| Æî¶«ÏØ| µÀÕæ| ¸»Ô£ÏØ| ÕòêãÏØ| ±±íÕÇø| äØÌ¶ÏØ| ¹ãÆ½ÏØ| ÌÒÔ°ÏØ|