??xml version="1.0" encoding="utf-8" standalone="yes"?>sm性调教片在线观看,99re6这里只有精品,久久日本片精品aaaaa国产http://www.aygfsteel.com/sunjavaer/category/2595.htmlzh-cnFri, 14 Jul 2017 03:24:03 GMTFri, 14 Jul 2017 03:24:03 GMT60CyclicBarrier 单D?/title><link>http://www.aygfsteel.com/sunjavaer/archive/2017/07/13/432663.html</link><dc:creator>丑男</dc:creator><author>丑男</author><pubDate>Thu, 13 Jul 2017 03:39:00 GMT</pubDate><guid>http://www.aygfsteel.com/sunjavaer/archive/2017/07/13/432663.html</guid><wfw:comment>http://www.aygfsteel.com/sunjavaer/comments/432663.html</wfw:comment><comments>http://www.aygfsteel.com/sunjavaer/archive/2017/07/13/432663.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sunjavaer/comments/commentRss/432663.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sunjavaer/services/trackbacks/432663.html</trackback:ping><description><![CDATA[一句话解释Q预备~~~开?br /><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; "> 1</span> <span style="color: #0000FF; ">import</span> java.util.concurrent.BrokenBarrierException;<br /><span style="color: #008080; "> 2</span> <span style="color: #0000FF; ">import</span> java.util.concurrent.CyclicBarrier;<br /><span style="color: #008080; "> 3</span> <br /><span style="color: #008080; "> 4</span> <span style="color: #0000FF; ">import</span> org.slf4j.Logger;<br /><span style="color: #008080; "> 5</span> <span style="color: #0000FF; ">import</span> org.slf4j.LoggerFactory;<br /><span style="color: #008080; "> 6</span> <br /><span style="color: #008080; "> 7</span> <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> CyclicBarrierLearn {<br /><span style="color: #008080; "> 8</span>     <br /><span style="color: #008080; "> 9</span>     <span style="color: #0000FF; ">private</span> Logger log = LoggerFactory.getLogger(CyclicBarrierLearn.<span style="color: #0000FF; ">class</span>);<br /><span style="color: #008080; ">10</span>     <br /><span style="color: #008080; ">11</span>     <span style="color: #0000FF; ">private</span> <span style="color: #0000FF; ">class</span> Work <span style="color: #0000FF; ">extends</span> Thread {<br /><span style="color: #008080; ">12</span>         <br /><span style="color: #008080; ">13</span>         <span style="color: #0000FF; ">private</span> String name;<br /><span style="color: #008080; ">14</span>         <span style="color: #0000FF; ">private</span> CyclicBarrier cyclicBarrier;<br /><span style="color: #008080; ">15</span>         <br /><span style="color: #008080; ">16</span>         <span style="color: #0000FF; ">public</span> Work(String name, CyclicBarrier cyclicBarrier) {<br /><span style="color: #008080; ">17</span>             <span style="color: #0000FF; ">this</span>.name = name;<br /><span style="color: #008080; ">18</span>             <span style="color: #0000FF; ">this</span>.cyclicBarrier = cyclicBarrier;<br /><span style="color: #008080; ">19</span>         }<br /><span style="color: #008080; ">20</span>         <br /><span style="color: #008080; ">21</span>         @Override<br /><span style="color: #008080; ">22</span>         <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> run() {<br /><span style="color: #008080; ">23</span>             <span style="color: #0000FF; ">try</span> {<br /><span style="color: #008080; ">24</span>                 log.debug("thread name: " + name + " waiting work");<br /><span style="color: #008080; ">25</span>                 cyclicBarrier.await();<br /><span style="color: #008080; ">26</span>                 log.debug("thread name: " + name + " working");<br /><span style="color: #008080; ">27</span>             } <span style="color: #0000FF; ">catch</span> (InterruptedException e) {<br /><span style="color: #008080; ">28</span>                 e.printStackTrace();<br /><span style="color: #008080; ">29</span>             } <span style="color: #0000FF; ">catch</span> (BrokenBarrierException e) {<br /><span style="color: #008080; ">30</span>                 e.printStackTrace();<br /><span style="color: #008080; ">31</span>             }<br /><span style="color: #008080; ">32</span>             <br /><span style="color: #008080; ">33</span>         }<br /><span style="color: #008080; ">34</span>     }<br /><span style="color: #008080; ">35</span>     <br /><span style="color: #008080; ">36</span>     <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> cyclicBarrier() {<br /><span style="color: #008080; ">37</span>         CyclicBarrier cyclicBarrier = <span style="color: #0000FF; ">new</span> CyclicBarrier(50, <span style="color: #0000FF; ">new</span> Runnable() {<br /><span style="color: #008080; ">38</span>             <br /><span style="color: #008080; ">39</span>             @Override<br /><span style="color: #008080; ">40</span>             <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> run() {<br /><span style="color: #008080; ">41</span>                 log.debug("let's begin work");<br /><span style="color: #008080; ">42</span>             }<br /><span style="color: #008080; ">43</span>         });<br /><span style="color: #008080; ">44</span>         <br /><span style="color: #008080; ">45</span>         <span style="color: #0000FF; ">for</span> (<span style="color: #0000FF; ">int</span> i = 0; i < cyclicBarrier.getParties(); i++) {<br /><span style="color: #008080; ">46</span>             Work work = <span style="color: #0000FF; ">new</span> Work(String.valueOf(i), cyclicBarrier);<br /><span style="color: #008080; ">47</span>             work.start();<br /><span style="color: #008080; ">48</span>         }<br /><span style="color: #008080; ">49</span>         <br /><span style="color: #008080; ">50</span>     }<br /><span style="color: #008080; ">51</span> <br /><span style="color: #008080; ">52</span>     <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">static</span> <span style="color: #0000FF; ">void</span> main(String[] args) {<br /><span style="color: #008080; ">53</span>         CyclicBarrierLearn cyclicBarrierLearn = <span style="color: #0000FF; ">new</span> CyclicBarrierLearn();<br /><span style="color: #008080; ">54</span>         cyclicBarrierLearn.cyclicBarrier();<br /><span style="color: #008080; ">55</span> <br /><span style="color: #008080; ">56</span>     }<br /><span style="color: #008080; ">57</span> <br /><span style="color: #008080; ">58</span> }<br /><span style="color: #008080; ">59</span> </div><img src ="http://www.aygfsteel.com/sunjavaer/aggbug/432663.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sunjavaer/" target="_blank">丑男</a> 2017-07-13 11:39 <a href="http://www.aygfsteel.com/sunjavaer/archive/2017/07/13/432663.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CountDownLatch 单D?/title><link>http://www.aygfsteel.com/sunjavaer/archive/2017/07/13/432662.html</link><dc:creator>丑男</dc:creator><author>丑男</author><pubDate>Thu, 13 Jul 2017 03:18:00 GMT</pubDate><guid>http://www.aygfsteel.com/sunjavaer/archive/2017/07/13/432662.html</guid><wfw:comment>http://www.aygfsteel.com/sunjavaer/comments/432662.html</wfw:comment><comments>http://www.aygfsteel.com/sunjavaer/archive/2017/07/13/432662.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sunjavaer/comments/commentRss/432662.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sunjavaer/services/trackbacks/432662.html</trackback:ping><description><![CDATA[一句话解释Q主U程dQ其他线E完成后Q主U程被唤醒后l箋执行<br /><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; "> 1</span> <span style="color: #0000FF; ">import</span> java.util.Random;<br /><span style="color: #008080; "> 2</span> <span style="color: #0000FF; ">import</span> java.util.concurrent.CountDownLatch;<br /><span style="color: #008080; "> 3</span> <br /><span style="color: #008080; "> 4</span> <span style="color: #0000FF; ">import</span> org.slf4j.Logger;<br /><span style="color: #008080; "> 5</span> <span style="color: #0000FF; ">import</span> org.slf4j.LoggerFactory;<br /><span style="color: #008080; "> 6</span> <br /><span style="color: #008080; "> 7</span> <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> CountDownLatchLearn {<br /><span style="color: #008080; "> 8</span>     <br /><span style="color: #008080; "> 9</span>     <span style="color: #0000FF; ">private</span> Logger log = LoggerFactory.getLogger(CountDownLatchLearn.<span style="color: #0000FF; ">class</span>);<br /><span style="color: #008080; ">10</span>     <span style="color: #0000FF; ">private</span> CountDownLatch countDownLatch;<br /><span style="color: #008080; ">11</span>     <br /><span style="color: #008080; ">12</span>     <span style="color: #0000FF; ">public</span> CountDownLatchLearn() {<br /><span style="color: #008080; ">13</span>         countDownLatch = <span style="color: #0000FF; ">new</span> CountDownLatch(50);<br /><span style="color: #008080; ">14</span>     }<br /><span style="color: #008080; ">15</span>     <br /><span style="color: #008080; ">16</span>     <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> countDown() {<br /><span style="color: #008080; ">17</span>         Long count = countDownLatch.getCount();<br /><span style="color: #008080; ">18</span>         log.debug("countDownLatch count is:" + count.toString());<br /><span style="color: #008080; ">19</span>         <br /><span style="color: #008080; ">20</span>         <span style="color: #0000FF; ">for</span> (<span style="color: #0000FF; ">int</span> i = 0; i < count; i++) {<br /><span style="color: #008080; ">21</span>             Work work = <span style="color: #0000FF; ">new</span> Work(String.valueOf(i), countDownLatch);<br /><span style="color: #008080; ">22</span>             work.start();<br /><span style="color: #008080; ">23</span>         }<br /><span style="color: #008080; ">24</span>         <span style="color: #0000FF; ">try</span> {<br /><span style="color: #008080; ">25</span>             countDownLatch.await();<br /><span style="color: #008080; ">26</span>         } <span style="color: #0000FF; ">catch</span> (InterruptedException e) {<br /><span style="color: #008080; ">27</span>             e.printStackTrace();<br /><span style="color: #008080; ">28</span>         }<br /><span style="color: #008080; ">29</span>         log.debug("work finish!!!");<br /><span style="color: #008080; ">30</span>     }<br /><span style="color: #008080; ">31</span>     <br /><span style="color: #008080; ">32</span>     <span style="color: #0000FF; ">private</span> <span style="color: #0000FF; ">class</span> Work <span style="color: #0000FF; ">extends</span> Thread {<br /><span style="color: #008080; ">33</span>         <br /><span style="color: #008080; ">34</span>         <span style="color: #0000FF; ">private</span> String name;<br /><span style="color: #008080; ">35</span>         <span style="color: #0000FF; ">private</span> CountDownLatch countDownLatch;<br /><span style="color: #008080; ">36</span>         <br /><span style="color: #008080; ">37</span>         <span style="color: #0000FF; ">public</span> Work(String name, CountDownLatch countDownLatch) {<br /><span style="color: #008080; ">38</span>             <span style="color: #0000FF; ">this</span>.name = name;<br /><span style="color: #008080; ">39</span>             <span style="color: #0000FF; ">this</span>.countDownLatch = countDownLatch;<br /><span style="color: #008080; ">40</span>         }<br /><span style="color: #008080; ">41</span>         <br /><span style="color: #008080; ">42</span>         @Override<br /><span style="color: #008080; ">43</span>         <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> run() {<br /><span style="color: #008080; ">44</span>             Random r = <span style="color: #0000FF; ">new</span> Random();<br /><span style="color: #008080; ">45</span>             <span style="color: #0000FF; ">int</span> sleep = r.nextInt(2000);<br /><span style="color: #008080; ">46</span>             <span style="color: #0000FF; ">try</span> {<br /><span style="color: #008080; ">47</span>                 log.debug("thread sleep: "+ sleep);<br /><span style="color: #008080; ">48</span>                 Thread.sleep(sleep);<br /><span style="color: #008080; ">49</span>             } <span style="color: #0000FF; ">catch</span> (InterruptedException e) {<br /><span style="color: #008080; ">50</span>                 e.printStackTrace();<br /><span style="color: #008080; ">51</span>             }<br /><span style="color: #008080; ">52</span>             log.debug("thread: " + name + ": do work");<br /><span style="color: #008080; ">53</span>             countDownLatch.countDown();<br /><span style="color: #008080; ">54</span>         }<br /><span style="color: #008080; ">55</span>     }<br /><span style="color: #008080; ">56</span> <br /><span style="color: #008080; ">57</span>     <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">static</span> <span style="color: #0000FF; ">void</span> main(String[] args) {<br /><span style="color: #008080; ">58</span>         System.out.println("main start!!!");<br /><span style="color: #008080; ">59</span>         <br /><span style="color: #008080; ">60</span>         CountDownLatchLearn countDownLatchLearn = <span style="color: #0000FF; ">new</span> CountDownLatchLearn();<br /><span style="color: #008080; ">61</span>         countDownLatchLearn.countDown();<br /><span style="color: #008080; ">62</span>         <br /><span style="color: #008080; ">63</span>         System.out.println("main end!!!");<br /><span style="color: #008080; ">64</span>     }<br /><span style="color: #008080; ">65</span> <br /><span style="color: #008080; ">66</span> }</div><img src ="http://www.aygfsteel.com/sunjavaer/aggbug/432662.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sunjavaer/" target="_blank">丑男</a> 2017-07-13 11:18 <a href="http://www.aygfsteel.com/sunjavaer/archive/2017/07/13/432662.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转脓]jasperreport可以用Collection做ؓ数据?/title><link>http://www.aygfsteel.com/sunjavaer/archive/2005/12/11/23371.html</link><dc:creator>丑男</dc:creator><author>丑男</author><pubDate>Sun, 11 Dec 2005 10:12:00 GMT</pubDate><guid>http://www.aygfsteel.com/sunjavaer/archive/2005/12/11/23371.html</guid><wfw:comment>http://www.aygfsteel.com/sunjavaer/comments/23371.html</wfw:comment><comments>http://www.aygfsteel.com/sunjavaer/archive/2005/12/11/23371.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sunjavaer/comments/commentRss/23371.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sunjavaer/services/trackbacks/23371.html</trackback:ping><description><![CDATA[<SPAN style="COLOR: #000000"> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Code_Closed_Image onclick="this.style.display='none'; Code_Closed_Text.style.display='none'; Code_Open_Image.style.display='inline'; Code_Open_Text.style.display='inline';" height=16 src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" width=11 align=top><IMG id=Code_Open_Image style="DISPLAY: none" onclick="this.style.display='none'; Code_Open_Text.style.display='none'; Code_Closed_Image.style.display='inline'; Code_Closed_Text.style.display='inline';" height=16 src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" width=11 align=top><SPAN id=Code_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"></SPAN><SPAN id=Code_Open_Text style="DISPLAY: none"><BR><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><SPAN style="COLOR: #008080"> 1</SPAN><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000"><%</SPAN><SPAN style="COLOR: #000000">@ page contentType</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">text/html;charset=GBK</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">%></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><%</SPAN><SPAN style="COLOR: #000000">@ page </SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">dori.jasper.engine.*</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">%></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><%</SPAN><SPAN style="COLOR: #000000">@ page </SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">java.util.*</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">%></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080"> 4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><%</SPAN><SPAN style="COLOR: #000000">@ page </SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">java.io.*</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">%></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080"> 5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><%</SPAN><SPAN style="COLOR: #000000">@ page </SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">java.sql.*</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">%></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080"> 6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><%</SPAN><SPAN style="COLOR: #000000">@ page </SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">com.zx.report.util.CarUse</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">%></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><%</SPAN><SPAN style="COLOR: #000000">@ page </SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">dori.jasper.engine.data.*</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">%></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080"> 8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><%</SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080"> 9<SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN></SPAN><SPAN style="COLOR: #000000">Connection conn </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">; <BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>Statement st </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">; <BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>ResultSet rs </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">; <BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">byte</SPAN><SPAN style="COLOR: #000000">[] bytes </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">; <BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>List carUseList</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> ArrayList(); <BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_420_2737_Open_Image onclick="this.style.display='none'; Codehighlighter1_420_2737_Open_Text.style.display='none'; Codehighlighter1_420_2737_Closed_Image.style.display='inline'; Codehighlighter1_420_2737_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_420_2737_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_420_2737_Closed_Text.style.display='none'; Codehighlighter1_420_2737_Open_Image.style.display='inline'; Codehighlighter1_420_2737_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN id=Codehighlighter1_420_2737_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_420_2737_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>Class.forName(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">com.microsoft.jdbc.sqlserver.SQLServerDriver</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">); <BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>conn </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">DriverManager.getConnection(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">jdbc:microsoft:sqlserver://10.10.10.207:1433;DatabaseName=report;user=sa;password=111111</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">); <BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">以输入流方式 </SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">   InputStream reportFile </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> getClass().getClassLoader().getResourceAsStream(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">carUserBd.jasper</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">); <BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">以reportFile方式 <BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">File reportFile =new File(request.getRealPath("/report/carUserBd.jasper")); </SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>Map parameters </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> HashMap(); <BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>String sqlCarUser</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">SELECT car.carNo, dept.Name , people.peopleName,carUse.useDescription ,</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> carUse.beginTime , carUse.planEndTime , carUse.comment , carUse.driver,</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> carUse.peopleNumber ,OneWay= case carUse.isOneWay  when 0 then '双程'  else '单程'  end, </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">isFirst= case carUse.priority when 0  then '? when  1  then  '?  else  '?  end, carUse.start , </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">33</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">carUse.destination , people.peopleName as ratifier FROM DEPT_CARUSELOG carUse , DEPT_CARINFO car , </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">34</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ADMIN_ORGANIZATION dept , PUBLIC_PEOPLEINFO people WHERE carUse.id=290 and </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">35</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">caruse.carId=car.carId and carUse.departId=dept.id and carUse.peopleId=people.peopleId</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">; <BR></SPAN><SPAN style="COLOR: #008080">36</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">37</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>st </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> conn.createStatement(); <BR></SPAN><SPAN style="COLOR: #008080">38</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>rs </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> st.executeQuery(sqlCarUser); <BR></SPAN><SPAN style="COLOR: #008080">39</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">40</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_1595_2192_Open_Image onclick="this.style.display='none'; Codehighlighter1_1595_2192_Open_Text.style.display='none'; Codehighlighter1_1595_2192_Closed_Image.style.display='inline'; Codehighlighter1_1595_2192_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_1595_2192_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1595_2192_Closed_Text.style.display='none'; Codehighlighter1_1595_2192_Open_Image.style.display='inline'; Codehighlighter1_1595_2192_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">(rs.next())</SPAN><SPAN id=Codehighlighter1_1595_2192_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_1595_2192_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">41</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>CarUse carUse</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> CarUse(); <BR></SPAN><SPAN style="COLOR: #008080">42</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setCarNo(rs.getString(</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">43</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setName(rs.getString(</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">44</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setPeopleName(rs.getString(</SPAN><SPAN style="COLOR: #000000">3</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">45</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setUseDescription(rs.getString(</SPAN><SPAN style="COLOR: #000000">4</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">46</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setBeginTime(rs.getDate(</SPAN><SPAN style="COLOR: #000000">5</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">47</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setPlanEndTime(rs.getDate(</SPAN><SPAN style="COLOR: #000000">6</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">48</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setComment(rs.getString(</SPAN><SPAN style="COLOR: #000000">7</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">49</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setDriver(rs.getString(</SPAN><SPAN style="COLOR: #000000">8</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">50</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setPeopleNumber(rs.getString(</SPAN><SPAN style="COLOR: #000000">9</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">51</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setOneWay(rs.getString(</SPAN><SPAN style="COLOR: #000000">10</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">52</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setIsFirst(rs.getString(</SPAN><SPAN style="COLOR: #000000">11</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">53</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setStart(rs.getString(</SPAN><SPAN style="COLOR: #000000">12</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">54</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setDestination(rs.getString(</SPAN><SPAN style="COLOR: #000000">13</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">55</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUse.setRatifier(rs.getString(</SPAN><SPAN style="COLOR: #000000">14</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">56</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">57</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>carUseList.add(carUse); <BR></SPAN><SPAN style="COLOR: #008080">58</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">59</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">60</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">61</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>JRBeanCollectionDataSource ds </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> JRBeanCollectionDataSource(carUseList); <BR></SPAN><SPAN style="COLOR: #008080">62</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">63</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>bytes </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">64</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>JasperRunManager.runReportToPdf( <BR></SPAN><SPAN style="COLOR: #008080">65</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>reportFile, <BR></SPAN><SPAN style="COLOR: #008080">66</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>parameters, <BR></SPAN><SPAN style="COLOR: #008080">67</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>ds); <BR></SPAN><SPAN style="COLOR: #008080">68</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>String fileName </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">test.pdf</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">; <BR></SPAN><SPAN style="COLOR: #008080">69</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>response.setContentType(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">application/pdf</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">); <BR></SPAN><SPAN style="COLOR: #008080">70</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>response.addHeader( <BR></SPAN><SPAN style="COLOR: #008080">71</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Content-Disposition</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">, <BR></SPAN><SPAN style="COLOR: #008080">72</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">attachment;filename=\</SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000"> + fileName); </SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">73</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">74</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>response.setContentLength(bytes.length); <BR></SPAN><SPAN style="COLOR: #008080">75</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>ServletOutputStream ouputStream </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> response.getOutputStream(); <BR></SPAN><SPAN style="COLOR: #008080">76</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">77</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>System.out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">5</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">); <BR></SPAN><SPAN style="COLOR: #008080">78</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>ouputStream.write(bytes, </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">, bytes.length); <BR></SPAN><SPAN style="COLOR: #008080">79</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>ouputStream.flush(); <BR></SPAN><SPAN style="COLOR: #008080">80</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>ouputStream.close(); <BR></SPAN><SPAN style="COLOR: #008080">81</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">82</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_2765_2830_Open_Image onclick="this.style.display='none'; Codehighlighter1_2765_2830_Open_Text.style.display='none'; Codehighlighter1_2765_2830_Closed_Image.style.display='inline'; Codehighlighter1_2765_2830_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_2765_2830_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2765_2830_Closed_Text.style.display='none'; Codehighlighter1_2765_2830_Open_Image.style.display='inline'; Codehighlighter1_2765_2830_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000"> (SQLException sqle) </SPAN><SPAN id=Codehighlighter1_2765_2830_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_2765_2830_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">83</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">84</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>System.out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">SQLException:</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> sqle.getMessage()); <BR></SPAN><SPAN style="COLOR: #008080">85</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">86</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_2854_2879_Open_Image onclick="this.style.display='none'; Codehighlighter1_2854_2879_Open_Text.style.display='none'; Codehighlighter1_2854_2879_Closed_Image.style.display='inline'; Codehighlighter1_2854_2879_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_2854_2879_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2854_2879_Closed_Text.style.display='none'; Codehighlighter1_2854_2879_Open_Image.style.display='inline'; Codehighlighter1_2854_2879_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000"> (JRException e) </SPAN><SPAN id=Codehighlighter1_2854_2879_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_2854_2879_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">87</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>e.printStackTrace(); <BR></SPAN><SPAN style="COLOR: #008080">88</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_2914_2921_Open_Image onclick="this.style.display='none'; Codehighlighter1_2914_2921_Open_Text.style.display='none'; Codehighlighter1_2914_2921_Closed_Image.style.display='inline'; Codehighlighter1_2914_2921_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_2914_2921_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2914_2921_Closed_Text.style.display='none'; Codehighlighter1_2914_2921_Open_Image.style.display='inline'; Codehighlighter1_2914_2921_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(ClassNotFoundException cnfe)</SPAN><SPAN id=Codehighlighter1_2914_2921_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_2914_2921_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">89</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">90</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">91</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">92</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">93</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">%></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">94</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">95</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top> </SPAN></SPAN></DIV><BR><BR>jasperreport可以用Collection做ؓ数据源,q种方式比用Connection方式更ؓ灉|方便 <BR><IMG height=16 src="http://sgsoft.cnblogs.com/Images/OutliningIndicators/None.gif" width=11 align=top></SPAN> <img src ="http://www.aygfsteel.com/sunjavaer/aggbug/23371.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sunjavaer/" target="_blank">丑男</a> 2005-12-11 18:12 <a href="http://www.aygfsteel.com/sunjavaer/archive/2005/12/11/23371.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转帖]学习Reflectionhttp://www.aygfsteel.com/sunjavaer/archive/2005/08/07/9497.html丑男丑男Sat, 06 Aug 2005 17:02:00 GMThttp://www.aygfsteel.com/sunjavaer/archive/2005/08/07/9497.htmlhttp://www.aygfsteel.com/sunjavaer/comments/9497.htmlhttp://www.aygfsteel.com/sunjavaer/archive/2005/08/07/9497.html#Feedback0http://www.aygfsteel.com/sunjavaer/comments/commentRss/9497.htmlhttp://www.aygfsteel.com/sunjavaer/services/trackbacks/9497.htmlReflection ?Java E序开发语a的特征之一Q它允许q行中的 Java E序对自w进行检查,或者说“自审”,q能直接操作E序的内部属性。例如,使用它能获得 Java cM各成员的名称q显C出来?/DIV>
Java 的这一能力在实际应用中也许用得不是很多Q但是在其它的程序设计语a中根本就不存在这一Ҏ。例如,Pascal、C 或?C++ 中就没有办法在程序中获得函数定义相关的信息?/DIV>
JavaBean ?reflection 的实际应用之一Q它能让一些工具可视化的操作Y件组件。这些工具通过 reflection 动态的载入q取?Java lg(c? 的属性?/DIV>
 
1. 一个简单的例子
考虑下面q个单的例子Q让我们看看 reflection 是如何工作的?/DIV>
import java.lang.reflect.*;
public class DumpMethods {
   public static void main(String args[]) {
       try {
           Class c = Class.forName(args[0]);
           Method m[] = c.getDeclaredMethods();
           for (int i = 0; i < m.length; i++)
               System.out.println(m[i].toString());
       } catch (Throwable e) {
           System.err.println(e);
       }
   }
}
按如下语句执行:
java DumpMethods java.util.Stack
它的l果输出为:
public java.lang.Object java.util.Stack.push(java.lang.Object)
public synchronized java.lang.Object java.util.Stack.pop()
public synchronized java.lang.Object java.util.Stack.peek()
public boolean java.util.Stack.empty()
public synchronized int java.util.Stack.search(java.lang.Object)
q样列Zjava.util.Stack cȝ各方法名以及它们的限制符和返回类型?/DIV>
q个E序使用 Class.forName 载入指定的类Q然后调?getDeclaredMethods 来获取这个类中定义了的方法列表。java.lang.reflect.Methods 是用来描q某个类中单个方法的一个类?/DIV>
2.开始?Reflection
用于 reflection 的类Q如 MethodQ可以在 java.lang.relfect 包中扑ֈ。用这些类的时候必要遵@三个步骤Q第一步是获得你想操作的类?java.lang.Class 对象。在q行中的 Java E序中,?java.lang.Class cL描述cd接口{?/DIV>
下面是获得一?Class 对象的方法之一Q?/DIV>
Class c = Class.forName("java.lang.String");
q条语句得到一?String cȝcd象。还有另一U方法,如下面的语句Q?/DIV>
Class c = int.class;
或?/DIV>
Class c = Integer.TYPE;
它们可获得基本类型的cM息。其中后一U方法中讉K的是基本cd的封装类 (?Integer) 中预先定义好?TYPE 字段?/DIV>
W二步是调用诸如 getDeclaredMethods 的方法,以取得该cM定义的所有方法的列表?/DIV>
一旦取得这个信息,可以进行第三步了——?reflection API 来操作这些信息,如下面这D代码:
Class c = Class.forName("java.lang.String");
Method m[] = c.getDeclaredMethods();
System.out.println(m[0].toString());
它将以文本方式打印出 String 中定义的W一个方法的原型?/DIV>
在下面的例子中,q三个步骤将Z?reflection 处理Ҏ应用E序提供例证?/DIV>
模拟 instanceof 操作W?/DIV>
得到cM息之后,通常下一个步骤就是解军_?Class 对象的一些基本的问题。例如,Class.isInstance Ҏ可以用于模拟 instanceof 操作W:
class A {
}
public class instance1 {
   public static void main(String args[]) {
       try {
           Class cls = Class.forName("A");
           boolean b1 = cls.isInstance(new Integer(37));
           System.out.println(b1);
           boolean b2 = cls.isInstance(new A());
           System.out.println(b2);
       } catch (Throwable e) {
           System.err.println(e);
       }
   }
}
在这个例子中创徏了一?A cȝ Class 对象Q然后检查一些对象是否是 A 的实例。Integer(37) 不是Q但 new A() 是?/DIV>
3.扑ևcȝҎ
扑և一个类中定义了些什么方法,q是一个非常有价g非常基础?reflection 用法。下面的代码实Cq一用法Q?/DIV>
import java.lang.reflect.*;
public class method1 {
   private int f1(Object p, int x) throws NullPointerException {
       if (p == null)
           throw new NullPointerException();
       return x;
   }
   public static void main(String args[]) {
       try {
           Class cls = Class.forName("method1");
           Method methlist[] = cls.getDeclaredMethods();
           for (int i = 0; i < methlist.length; i++) {
               Method m = methlist[i];
               System.out.println("name = " + m.getName());
               System.out.println("decl class = " + m.getDeclaringClass());
               Class pvec[] = m.getParameterTypes();
               for (int j = 0; j < pvec.length; j++)
                   System.out.println("param #" + j + " " + pvec[j]);
               Class evec[] = m.getExceptionTypes();
               for (int j = 0; j < evec.length; j++)
                   System.out.println("exc #" + j + " " + evec[j]);
               System.out.println("return type = " + m.getReturnType());
               System.out.println("-----");
           }
       } catch (Throwable e) {
           System.err.println(e);
       }
   }
}
q个E序首先取得 method1 cȝ描述Q然后调?getDeclaredMethods 来获取一pd?Method 对象Q它们分别描qC定义在类中的每一个方法,包括 public Ҏ、protected Ҏ、package Ҏ?private Ҏ{。如果你在程序中使用 getMethods 来代?getDeclaredMethodsQ你q能获得l承来的各个Ҏ的信息?/DIV>
取得?Method 对象列表之后Q要昄q些Ҏ的参数类型、异常类型和q回值类型等׃难了。这些类型是基本cdq是cȝ型,都可以由描述cȝ对象按顺序给出?/DIV>
输出的结果如下:
name = f1
decl class = class method1
param #0 class java.lang.Object
param #1 int
exc #0 class java.lang.NullPointerException
return type = int
-----
name = main
decl class = class method1
param #0 class [Ljava.lang.String;
return type = void
-----

4.获取构造器信息
获取cL造器的用法与上述获取Ҏ的用法类|如:
import java.lang.reflect.*;
public class constructor1 {
   public constructor1() {
   }
   protected constructor1(int i, double d) {
   }
   public static void main(String args[]) {
       try {
           Class cls = Class.forName("constructor1");
           Constructor ctorlist[] = cls.getDeclaredConstructors();
           for (int i = 0; i < ctorlist.length; i++) {
               Constructor ct = ctorlist[i];
               System.out.println("name = " + ct.getName());
               System.out.println("decl class = " + ct.getDeclaringClass());
               Class pvec[] = ct.getParameterTypes();
               for (int j = 0; j < pvec.length; j++)
                   System.out.println("param #" + j + " " + pvec[j]);
               Class evec[] = ct.getExceptionTypes();
               for (int j = 0; j < evec.length; j++)
                   System.out.println("exc #" + j + " " + evec[j]);
               System.out.println("-----");
           }
       } catch (Throwable e) {
           System.err.println(e);
       }
   }
}
q个例子中没能获得返回类型的相关信息Q那是因为构造器没有q回cd?/DIV>
q个E序q行的结果是Q?/DIV>
name = constructor1
decl class = class constructor1
-----
name = constructor1
decl class = class constructor1
param #0 int
param #1 double
-----
5.获取cȝ字段(?
扑և一个类中定义了哪些数据字段也是可能的,下面的代码就在干q个事情Q?/DIV>

import java.lang.reflect.*;
public class field1 {
   private double d;
   public static final int i = 37;
   String s = "testing";
   public static void main(String args[]) {
       try {
           Class cls = Class.forName("field1");
           Field fieldlist[] = cls.getDeclaredFields();
           for (int i = 0; i < fieldlist.length; i++) {
               Field fld = fieldlist[i];
               System.out.println("name = " + fld.getName());
               System.out.println("decl class = " + fld.getDeclaringClass());
               System.out.println("type = " + fld.getType());
               int mod = fld.getModifiers();
               System.out.println("modifiers = " + Modifier.toString(mod));
               System.out.println("-----");
           }
       } catch (Throwable e) {
           System.err.println(e);
       }
   }
}
q个例子和前面那个例子非常相伹{例中用了一个新东西 ModifierQ它也是一?reflection c,用来描述字段成员的修饰语Q如“private int”。这些修饰语自n由整数描qͼ而且使用 Modifier.toString 来返回以“官方”顺序排列的字符串描q?(如“static”在“final”之?。这个程序的输出是:
name = d
decl class = class field1
type = double
modifiers = private
-----
name = i
decl class = class field1
type = int
modifiers = public static final
-----
name = s
decl class = class field1
type = class java.lang.String
modifiers =
-----
和获取方法的情况一下,获取字段的时候也可以只取得在当前cMx了的字段信息 (getDeclaredFields)Q或者也可以取得父类中定义的字段 (getFields) ?/DIV>

6.ҎҎ的名U来执行Ҏ
文本到这里,所丄例子无一例外都与如何获取cȝ信息有关。我们也可以?reflection 来做一些其它的事情Q比如执行一个指定了名称的方法。下面的CZ演示了这一操作Q?/DIV>
import java.lang.reflect.*;
public class method2 {
   public int add(int a, int b) {
       return a + b;
   }
   public static void main(String args[]) {
       try {
           Class cls = Class.forName("method2");
           Class partypes[] = new Class[2];
           partypes[0] = Integer.TYPE;
           partypes[1] = Integer.TYPE;
           Method meth = cls.getMethod("add", partypes);
           method2 methobj = new method2();
           Object arglist[] = new Object[2];
           arglist[0] = new Integer(37);
           arglist[1] = new Integer(47);
           Object retobj = meth.invoke(methobj, arglist);
           Integer retval = (Integer) retobj;
           System.out.println(retval.intvalue());
       } catch (Throwable e) {
           System.err.println(e);
       }
   }
}
假如一个程序在执行的某处的时候才知道需要执行某个方法,q个Ҏ的名U是在程序的q行q程中指定的 (例如QJavaBean 开发环境中׃做这L?Q那么上面的E序演示了如何做到?/DIV>
上例中,getMethod 用于查找一个具有两个整型参C名ؓ add 的方法。找到该Ҏq创Z相应?Method 对象之后Q在正确的对象实例中执行它。执行该Ҏ的时候,需要提供一个参数列表,q在上例中是分别包装了整?37 ?47 的两?Integer 对象。执行方法的q回的同h一?Integer 对象Q它装了返回?84?/DIV>
7.创徏新的对象
对于构造器Q则不能像执行方法那栯行,因ؓ执行一个构造器意味着创徏了一个新的对?(准确的说Q创Z个对象的q程包括分配内存和构造对?。所以,与上例最怼的例子如下:
import java.lang.reflect.*;
public class constructor2 {
   public constructor2() {
   }
   public constructor2(int a, int b) {
       System.out.println("a = " + a + " b = " + b);
   }
   public static void main(String args[]) {
       try {
           Class cls = Class.forName("constructor2");
           Class partypes[] = new Class[2];
           partypes[0] = Integer.TYPE;
           partypes[1] = Integer.TYPE;
           Constructor ct = cls.getConstructor(partypes);
           Object arglist[] = new Object[2];
           arglist[0] = new Integer(37);
           arglist[1] = new Integer(47);
           Object retobj = ct.newInstance(arglist);
       } catch (Throwable e) {
           System.err.println(e);
       }
   }
}
Ҏ指定的参数类型找到相应的构造函数ƈ执行它,以创Z个新的对象实例。用这U方法可以在E序q行时动态地创徏对象Q而不是在~译的时候创建对象,q一炚w常有价倹{?/DIV>
8.改变字段(?的?/DIV>
reflection 的还有一个用处就是改变对象数据字D늚倹{reflection 可以从正在运行的E序中根据名U找到对象的字段q改变它Q下面的例子可以说明q一点:
import java.lang.reflect.*;
public class field2 {
   public double d;
   public static void main(String args[]) {
       try {
           Class cls = Class.forName("field2");
           Field fld = cls.getField("d");
           field2 f2obj = new field2();
           System.out.println("d = " + f2obj.d);
           fld.setDouble(f2obj, 12.34);
           System.out.println("d = " + f2obj.d);
       } catch (Throwable e) {
           System.err.println(e);
       }
   }
}
q个例子中,字段 d 的D变ؓ?12.34?/DIV>
9.使用数组
本文介绍?reflection 的最后一U用法是创徏的操作数l。数l在 Java 语言中是一U特D的cȝ型,一个数l的引用可以赋给 Object 引用。观察下面的例子看看数组是怎么工作的:
import java.lang.reflect.*;
public class array1 {
   public static void main(String args[]) {
       try {
           Class cls = Class.forName("java.lang.String");
           Object arr = Array.newInstance(cls, 10);
           Array.set(arr, 5, "this is a test");
           String s = (String) Array.get(arr, 5);
           System.out.println(s);
       } catch (Throwable e) {
           System.err.println(e);
       }
   }
}
例中创徏?10 个单位长度的 String 数组QؓW?5 个位|的字符串赋了|最后将q个字符串从数组中取得ƈ打印了出来?/DIV>
下面q段代码提供了一个更复杂的例子:
import java.lang.reflect.*;
public class array2 {
   public static void main(String args[]) {
       int dims[] = new int[]{5, 10, 15};
       Object arr = Array.newInstance(Integer.TYPE, dims);
       Object arrobj = Array.get(arr, 3);
       Class cls = arrobj.getClass().getComponentType();
       System.out.println(cls);
       arrobj = Array.get(arrobj, 5);
       Array.setInt(arrobj, 10, 37);
       int arrcast[][][] = (int[][][]) arr;
       System.out.println(arrcast[3][5][10]);
   }
}
例中创徏了一?5 x 10 x 15 的整型数l,qؓ处于 [3][5][10] 的元素赋了gؓ 37。注意,多维数组实际上就是数l的数组Q例如,W一?Array.get 之后Qarrobj 是一?10 x 15 的数l。进而取得其中的一个元素,即长度ؓ 15 的数l,q?Array.setInt 为它的第 10 个元素赋倹{?/DIV>
注意创徏数组时的cd是动态的Q在~译时ƈ不知道其cd?BR>


丑男 2005-08-07 01:02 发表评论
]]>单应用日期类http://www.aygfsteel.com/sunjavaer/archive/2005/08/05/9440.html丑男丑男Fri, 05 Aug 2005 15:31:00 GMThttp://www.aygfsteel.com/sunjavaer/archive/2005/08/05/9440.htmlhttp://www.aygfsteel.com/sunjavaer/comments/9440.htmlhttp://www.aygfsteel.com/sunjavaer/archive/2005/08/05/9440.html#Feedback0http://www.aygfsteel.com/sunjavaer/comments/commentRss/9440.htmlhttp://www.aygfsteel.com/sunjavaer/services/trackbacks/9440.html   用到java.text.SimpleDateFormatQ其中参数如下:
   ssQ秒
   mmQ分
   hhQ小?BR>   EEEEQ星?BR>   MMMMQ月?BR>   ddQ日?BR>   yyyyQ年?BR>
        Date d = new Date();
        SimpleDateFormat sdf 
= new SimpleDateFormat("ss-mm-hh-EEEE-MMMM-dd-yyyy");
        System.
out.println(sdf.format(d));

q行l果
58-21-11-星期?七月-22-2005

2.DateFormat自带格式
        Date date = new Date(); 

        DateFormat shortDateFormat 
= DateFormat.getDateTimeInstance( DateFormat.SHORT, 
                                                                                                                 DateFormat.SHORT); 
           System.out.println(shortDateFormat.format(date));
           //输出l果      05-7-22 下午11:47


           DateFormat mediumDateFormat = DateFormat.getDateTimeInstance( DateFormat.MEDIUM,
                                                                                                                      DateFormat.MEDIUM); 
           System.out.println (mediumDateFormat.format(date));
           //输出l果       2005-7-22 23:48:11


           DateFormat longDateFormat = DateFormat.getDateTimeInstance( DateFormat.LONG, 
                                                                                                                DateFormat.LONG);
           System.out.println(longDateFormat.format(date));
           //输出l果      2005q??2?下午11?8?5U?/SPAN>


           DateFormat fullDateFormat = DateFormat.getDateTimeInstance( DateFormat.FULL,
                                                                                                               DateFormat.FULL);
           System.out.println (fullDateFormat.format(date));
           //输出l果      Saturday, September 29, 2001 8:44:45 PM EDT



丑男 2005-08-05 23:31 发表评论
]]>
վ֩ģ壺 | | ƽȪ| ƽ| ɽ| | | ϲ| | | ͬ| ʯɽ| ͷ| ˶| ɽ| ɽ| ԭ| «ɽ| | ʱ| Ӷ| | | մ| | Ѿ| | | ƽ| | | | ĵ| | | ɽ| »| բ| | | |