锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品久久久亚洲一区,久久久噜噜噜,欧美美女日韩http://www.aygfsteel.com/a3mao/zh-cnTue, 06 May 2025 03:40:20 GMTTue, 06 May 2025 03:40:20 GMT60Serializable瀵硅薄搴忓垪鍖栧疄渚?/title><link>http://www.aygfsteel.com/a3mao/archive/2006/11/09/80098.html</link><dc:creator>a3mao</dc:creator><author>a3mao</author><pubDate>Thu, 09 Nov 2006 04:22:00 GMT</pubDate><guid>http://www.aygfsteel.com/a3mao/archive/2006/11/09/80098.html</guid><wfw:comment>http://www.aygfsteel.com/a3mao/comments/80098.html</wfw:comment><comments>http://www.aygfsteel.com/a3mao/archive/2006/11/09/80098.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/a3mao/comments/commentRss/80098.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/a3mao/services/trackbacks/80098.html</trackback:ping><description><![CDATA[ <p> <font face="鏂板畫浣?> <font color="#7f0055"> <strong> <font size="1">杞嚜錛?/font> <a > <font size="1">http://www.j2medev.com/code/j2se/language/200602/1343.html</font> </a> <br /> <br /> <font size="1">import聽</font> </strong> <font size="1"> </font> </font> <font size="1"> <font color="#000000">java.io.FileInputStream;</font> <br /> <font color="#7f0055"> <b>import聽</b> </font> <font color="#000000">java.io.FileOutputStream;</font> <br /> <font color="#7f0055"> <b>import聽</b> </font> <font color="#000000">java.io.ObjectInputStream;</font> <br /> <font color="#7f0055"> <b>import聽</b> </font> <font color="#000000">java.io.ObjectOutputStream;</font> <br /> <font color="#7f0055"> <b>import聽</b> </font> <font color="#000000">java.io.Serializable;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#7f0055"> <b>public聽class聽</b> </font> <font color="#000000">CardReader聽</font> <font color="#000000">{</font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽static聽</b> </font> <font color="#7f0055"> <b>void聽</b> </font> <font color="#000000">main</font> <font color="#000000">(</font> <font color="#000000">String</font> <font color="#000000">[]聽</font> <font color="#000000">args</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">Card3聽card聽=聽</font> <font color="#7f0055"> <b>new聽</b> </font> <font color="#000000">Card3</font> <font color="#000000">(</font> <font color="#990000">12</font> <font color="#000000">,聽Card3.SPADES</font> <font color="#000000">)</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">System.out.println</font> <font color="#000000">(</font> <font color="#2a00ff">"Card聽to聽write聽is:聽"聽</font> <font color="#000000">+聽card</font> <font color="#000000">)</font> <font color="#000000">;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>try聽</b> </font> <font color="#000000">{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">FileOutputStream聽out聽=聽</font> <font color="#7f0055"> <b>new聽</b> </font> <font color="#000000">FileOutputStream</font> <font color="#000000">(</font> <font color="#2a00ff">"card.out"</font> <font color="#000000">)</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">ObjectOutputStream聽oos聽=聽</font> <font color="#7f0055"> <b>new聽</b> </font> <font color="#000000">ObjectOutputStream</font> <font color="#000000">(</font> <font color="#000000">out</font> <font color="#000000">)</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">oos.writeObject</font> <font color="#000000">(</font> <font color="#000000">card</font> <font color="#000000">)</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">oos.flush</font> <font color="#000000">()</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}聽</font> <font color="#7f0055"> <b>catch聽</b> </font> <font color="#000000">(</font> <font color="#000000">Exception聽e</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">System.out.println</font> <font color="#000000">(</font> <font color="#2a00ff">"Problem聽serializing:聽"聽</font> <font color="#000000">+聽e</font> <font color="#000000">)</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">Card3聽acard聽=聽</font> <font color="#7f0055"> <b>null</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>try聽</b> </font> <font color="#000000">{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">FileInputStream聽in聽=聽</font> <font color="#7f0055"> <b>new聽</b> </font> <font color="#000000">FileInputStream</font> <font color="#000000">(</font> <font color="#2a00ff">"card.out"</font> <font color="#000000">)</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">ObjectInputStream聽ois聽=聽</font> <font color="#7f0055"> <b>new聽</b> </font> <font color="#000000">ObjectInputStream</font> <font color="#000000">(</font> <font color="#000000">in</font> <font color="#000000">)</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">acard聽=聽</font> <font color="#000000">(</font> <font color="#000000">Card3</font> <font color="#000000">)聽(</font> <font color="#000000">ois.readObject</font> <font color="#000000">())</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}聽</font> <font color="#7f0055"> <b>catch聽</b> </font> <font color="#000000">(</font> <font color="#000000">Exception聽e</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">System.out.println</font> <font color="#000000">(</font> <font color="#2a00ff">"Problem聽serializing:聽"聽</font> <font color="#000000">+聽e</font> <font color="#000000">)</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">System.out.println</font> <font color="#000000">(</font> <font color="#2a00ff">"Card聽read聽is:聽"聽</font> <font color="#000000">+聽acard</font> <font color="#000000">)</font> <font color="#000000">;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#000000">}</font> <br /> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#7f0055"> <b>class聽</b> </font> <font color="#000000">Card3聽</font> <font color="#7f0055"> <b>implements聽</b> </font> <font color="#000000">Serializable聽</font> <font color="#000000">{</font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>private聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">suit聽=聽UNASSIGNED;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>private聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">number聽=聽UNASSIGNED;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽final聽static聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">UNASSIGNED聽=聽-</font> <font color="#990000">1</font> <font color="#000000">;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽final聽static聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">DIAMONDS聽=聽</font> <font color="#990000">1</font> <font color="#000000">;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽final聽static聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">CLUBS聽=聽</font> <font color="#990000">2</font> <font color="#000000">;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽final聽static聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">HEARTS聽=聽</font> <font color="#990000">3</font> <font color="#000000">;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽final聽static聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">SPADES聽=聽</font> <font color="#990000">4</font> <font color="#000000">;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽final聽static聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">ACE聽=聽</font> <font color="#990000">1</font> <font color="#000000">;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽final聽static聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">KING聽=聽</font> <font color="#990000">13</font> <font color="#000000">;</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽</b> </font> <font color="#000000">Card3</font> <font color="#000000">(</font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">number,聽</font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">suit</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>if聽</b> </font> <font color="#000000">(</font> <font color="#000000">isValidNumber</font> <font color="#000000">(</font> <font color="#000000">number</font> <font color="#000000">))聽{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>this</b> </font> <font color="#000000">.number聽=聽number;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}聽</font> <font color="#7f0055"> <b>else聽</b> </font> <font color="#000000">{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#3f7f5f">//Error</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>if聽</b> </font> <font color="#000000">(</font> <font color="#000000">isValidSuit</font> <font color="#000000">(</font> <font color="#000000">suit</font> <font color="#000000">))聽{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>this</b> </font> <font color="#000000">.suit聽=聽suit;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}聽</font> <font color="#7f0055"> <b>else聽</b> </font> <font color="#000000">{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#3f7f5f">//Error</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff">聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">getSuit</font> <font color="#000000">()聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>return聽</b> </font> <font color="#000000">suit;</font> <br /> <font color="#ffffff">聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">getNumber</font> <font color="#000000">()聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>return聽</b> </font> <font color="#000000">number;</font> <br /> <font color="#ffffff">聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽static聽</b> </font> <font color="#7f0055"> <b>boolean聽</b> </font> <font color="#000000">isValidNumber</font> <font color="#000000">(</font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">number</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>if聽</b> </font> <font color="#000000">(</font> <font color="#000000">number聽>=聽ACE聽&&聽number聽<=聽KING</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>return聽true</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}聽</font> <font color="#7f0055"> <b>else聽</b> </font> <font color="#000000">{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>return聽false</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff">聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽static聽</b> </font> <font color="#7f0055"> <b>boolean聽</b> </font> <font color="#000000">isValidSuit</font> <font color="#000000">(</font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">suit</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>if聽</b> </font> <font color="#000000">(</font> <font color="#000000">suit聽>=聽DIAMONDS聽&&聽suit聽<=聽SPADES</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>return聽true</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}聽</font> <font color="#7f0055"> <b>else聽</b> </font> <font color="#000000">{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>return聽false</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff">聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽</b> </font> <font color="#7f0055"> <b>boolean聽</b> </font> <font color="#000000">equals</font> <font color="#000000">(</font> <font color="#000000">Object聽obj</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>if聽</b> </font> <font color="#000000">(</font> <font color="#000000">obj聽</font> <font color="#7f0055"> <b>instanceof聽</b> </font> <font color="#000000">Card3</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">Card3聽card聽=聽</font> <font color="#000000">(</font> <font color="#000000">Card3</font> <font color="#000000">)聽</font> <font color="#000000">obj;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>if聽</b> </font> <font color="#000000">(</font> <font color="#000000">card.getNumber</font> <font color="#000000">()聽</font> <font color="#000000">==聽</font> <font color="#7f0055"> <b>this</b> </font> <font color="#000000">.number聽&&聽card.getSuit</font> <font color="#000000">()聽</font> <font color="#000000">==聽</font> <font color="#7f0055"> <b>this</b> </font> <font color="#000000">.suit</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽聽聽</font> <font color="#7f0055"> <b>return聽true</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">}聽</font> <font color="#7f0055"> <b>else聽</b> </font> <font color="#000000">{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽聽聽</font> <font color="#7f0055"> <b>return聽false</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}聽</font> <font color="#7f0055"> <b>else聽</b> </font> <font color="#000000">{</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>return聽false</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff">聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽</b> </font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">hashCode</font> <font color="#000000">()聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>return聽</b> </font> <font color="#000000">number聽*聽suit;</font> <br /> <font color="#ffffff">聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽</b> </font> <font color="#000000">String聽toString</font> <font color="#000000">()聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>return聽</b> </font> <font color="#000000">numberToString</font> <font color="#000000">(</font> <font color="#7f0055"> <b>this</b> </font> <font color="#000000">.number</font> <font color="#000000">)聽</font> <font color="#000000">+聽</font> <font color="#2a00ff">"聽of聽"聽</font> <font color="#000000">+聽suitToString</font> <font color="#000000">(</font> <font color="#7f0055"> <b>this</b> </font> <font color="#000000">.suit</font> <font color="#000000">)</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽static聽</b> </font> <font color="#000000">String聽numberToString</font> <font color="#000000">(</font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">number</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">String聽result聽=聽</font> <font color="#2a00ff">""</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>switch聽</b> </font> <font color="#000000">(</font> <font color="#000000">number</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#000000">ACE:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Ace"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#990000">2</font> <font color="#000000">:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Two"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#990000">3</font> <font color="#000000">:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Three"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#990000">4</font> <font color="#000000">:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Four"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#990000">5</font> <font color="#000000">:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Five"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#990000">6</font> <font color="#000000">:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Six"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#990000">7</font> <font color="#000000">:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Seven"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#990000">8</font> <font color="#000000">:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Eight"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#990000">9</font> <font color="#000000">:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Nine"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#990000">10</font> <font color="#000000">:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Ten"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#990000">11</font> <font color="#000000">:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Jack"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#990000">12</font> <font color="#000000">:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Queen"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#000000">KING:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"King"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#000000">UNASSIGNED:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Invalid聽Number"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>return聽</b> </font> <font color="#000000">result;</font> <br /> <font color="#ffffff">聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff"> </font> <br /> <font color="#ffffff">聽聽</font> <font color="#7f0055"> <b>public聽static聽</b> </font> <font color="#000000">String聽suitToString</font> <font color="#000000">(</font> <font color="#7f0055"> <b>int聽</b> </font> <font color="#000000">suit</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">String聽result聽=聽</font> <font color="#2a00ff">""</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>switch聽</b> </font> <font color="#000000">(</font> <font color="#000000">suit</font> <font color="#000000">)聽{</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#000000">DIAMONDS:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Diamonds"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#000000">CLUBS:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Clubs"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#000000">HEARTS:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Hearts"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#000000">SPADES:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Spades"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>case聽</b> </font> <font color="#000000">UNASSIGNED:</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#000000">result聽=聽</font> <font color="#2a00ff">"Invalid聽Suit"</font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽聽聽</font> <font color="#7f0055"> <b>break</b> </font> <font color="#000000">;</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#000000">}</font> <br /> <font color="#ffffff">聽聽聽聽</font> <font color="#7f0055"> <b>return聽</b> </font> <font color="#000000">result;</font> <br /> <font color="#ffffff">聽聽</font> <font color="#000000">}</font> <br /> <font color="#000000">}</font> </font> </font> </p> <img src ="http://www.aygfsteel.com/a3mao/aggbug/80098.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/a3mao/" target="_blank">a3mao</a> 2006-11-09 12:22 <a href="http://www.aygfsteel.com/a3mao/archive/2006/11/09/80098.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Serializablehttp://www.aygfsteel.com/a3mao/archive/2006/11/09/80094.htmla3maoa3maoThu, 09 Nov 2006 04:12:00 GMThttp://www.aygfsteel.com/a3mao/archive/2006/11/09/80094.htmlhttp://www.aygfsteel.com/a3mao/comments/80094.htmlhttp://www.aygfsteel.com/a3mao/archive/2006/11/09/80094.html#Feedback0http://www.aygfsteel.com/a3mao/comments/commentRss/80094.htmlhttp://www.aygfsteel.com/a3mao/services/trackbacks/80094.html鎺ュ彛 java.io.Serializable
public interface Serializable

瀹炵幇 java.io.Serializable 鎺ュ彛鐨勭被鏄彲搴忓垪鍖栫殑銆傛病鏈夊疄鐜版鎺ュ彛鐨勭被灝嗕笉鑳戒嬌瀹冧滑鐨勪換涓鐘舵佽搴忓垪鍖栨垨閫嗗簭鍒楀寲銆傚簭鍒楀寲綾葷殑鎵鏈夊瓙綾繪湰韜兘鏄彲搴忓垪鍖栫殑銆傝繖涓簭鍒楀寲鎺ュ彛娌℃湁浠諱綍鏂規(guī)硶鍜屽煙錛屼粎鐢ㄤ簬鏍囪瘑搴忓垪鍖栫殑璇剰銆?

鍏佽闈炲簭鍒楀寲綾葷殑瀛愮被鍨嬪簭鍒楀寲錛屽瓙綾誨瀷鍙互鍋囧畾璐熻矗淇濆瓨鍜屾仮澶嶇埗綾誨瀷鐨勫叕鏈夌殑銆佷繚鎶ょ殑鍜?濡傛灉鍙闂?鍖呯殑鍩熺殑鐘舵併傚彧瑕佽綾?鎵╁睍)鏈変竴涓棤鍙傛瀯閫犲瓙錛屽彲鍒濆鍖栧畠鐨勭姸鎬侊紝閭d箞瀛愮被鍨嬪氨鍙壙鎷呬笂榪拌亴璐c傚湪榪欑鎯呭喌涓嬬敵鏄庝竴涓彲搴忓垪鍖栫殑綾繪槸涓涓敊璇傛閿欒灝嗗湪榪愯鏃惰媯嫻嬨?

鍦ㄩ嗗簭鍒楀寲鏈熼棿錛屽皢浣跨敤闈炲簭鍒楀寲綾葷殑鍏敤鐨勬垨淇濇姢鐨勬棤鍙傛瀯閫犲瓙瀵瑰畠鐨勫煙榪涜鍒濆鍖栥傚彲搴忓垪鍖栧瓙綾誨繀欏昏兘璁塊棶鐖剁被鐨勬棤鍙傛瀯閫犲瓙銆傚畠鐨勬墍鏈夊煙灝嗕粠鐩稿簲嫻佷腑琚仮澶嶃?

褰撻亶鍘嗕竴涓浘璞℃椂錛屽緢鍙兘閬囧埌涓涓笉鏀寔搴忓垪鍖栨帴鍙g殑瀵硅薄銆傛鏃跺皢鎶涘嚭 NotSerializableException 寮傚父錛屼笖鏍囪瘑璇ラ潪搴忓垪鍖栧璞$被銆?

鍦ㄥ簭鍒楀寲澶勭悊榪囩▼涓渶瑕佺壒瀹氬彞鏌勭殑綾伙紝蹇呴』浣跨敤濡備笅榪欎簺鎭板綋鐨勬爣璁板疄鐜扮壒瀹氱殑鏂規(guī)硶錛?

 private void writeObject(java.io.ObjectOutputStream out)
     throws IOException
 private void readObject(java.io.ObjectInputStream in)
     throws IOException, ClassNotFoundException; 
 

writeObject 鏂規(guī)硶璐熻矗鍐欑壒瀹氱被鐨勫璞$殑鐘舵侊紝浠ヨ嚦鐩稿簲鐨?readObject 鏂規(guī)硶鑳芥仮澶嶅畠銆?閫氳繃璋冪敤 out.defaultWriteObject 鍙縺媧諱繚瀛樺璞″煙鐨勭己鐪佹満鍒躲傛鏂規(guī)硶涓嶅繀鍏沖績鐘舵佹槸灞炰簬瀹冪殑鐖剁被榪樻槸瀛愮被銆?浣跨敤 writeObject 鏂規(guī)硶鎴栧熀鏈被鍨嬫敮鎸佺殑 DataOutput 鏂規(guī)硶灝嗘瘡涓煙鐨勭姸鎬佷繚瀛樺埌 ObjectOutputStream 涓?

readObject 鏂規(guī)硶璐熻矗浠庢嫻佷腑璇誨彇騫舵仮澶嶇被鐨勫煙銆傚畠鍙兘璋冪敤 in.defaultReadObject 鏂規(guī)硶鏉ヨ皟鐢ㄨ瀵硅薄鐨勯潪闈欐佸拰闈炴殏鏃剁殑鍩熺殑緙虹渷鎭㈠鏈哄埗銆?defaultReadObject 鏂規(guī)硶浣跨敤璇ユ祦涓殑淇℃伅錛岀敤褰撳墠瀵硅薄涓殑宸插懡鍚嶅煙鍒嗛厤淇濆瓨鍦ㄦ祦涓瀵硅薄鐨勭浉搴斿煙銆傚綋綾誨凡鏀硅繘澧炲姞浜嗘柊鍩熸椂錛岃繖涓帴鍙d篃鍋氱浉搴斿鐞嗐傛鏂規(guī)硶涓嶅繀鍏沖績鐘舵佹槸灞炰簬瀹冪殑鐖剁被榪樻槸瀛愮被銆?浣跨敤 writeObject 鏂規(guī)硶鎴栧熀鏈被鍨嬫敮鎸佺殑 DataOutput 鏂規(guī)硶灝嗘瘡涓煙鐨勭姸鎬佷繚瀛樺埌 ObjectOutputStream 涓?/p>

a3mao 2006-11-09 12:12 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 景德镇市| 纳雍县| 手游| 宁德市| 永德县| 灵丘县| 光山县| 墨竹工卡县| 曲阳县| 高雄市| 容城县| 和政县| 射洪县| 济源市| 阳泉市| 舞阳县| 乌拉特前旗| 浮山县| 嘉义市| 抚顺县| 冕宁县| 太保市| 德安县| 永泰县| 新疆| 栖霞市| 岫岩| 饶阳县| 通许县| 丹寨县| 峨眉山市| 安平县| 囊谦县| 嘉义县| 库尔勒市| 都匀市| 平远县| 长乐市| 阜城县| 贵德县| 蕲春县|