ï»??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.htmlimportÂ
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.htmlimportÂ
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基础å¦ä¹ 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.htmlimportÂ
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
)
;
   Â
}
 Â
}
}
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.htmlimportÂ
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"
))
;
   Â
}
}
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.htmlimportÂ
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
())
;
   Â
}
 Â
}
}
 Â
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.htmlimportÂ
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.htmlimportÂ
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
))
;
 Â
}
}
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 +Â
"Â "
)
;
   Â
}
 Â
}
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
)
;
 Â
}
}
 Â
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
()
;
   Â
}
 Â
}
}
 Â
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
))
;
   Â
}
 Â
}
}