锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲乱码卡三乱码新区,亚洲一区二区三区夜色,亚洲国产精品无码观看久久http://www.tkk7.com/sunjavaer/category/2595.htmlzh-cnFri, 14 Jul 2017 03:24:03 GMTFri, 14 Jul 2017 03:24:03 GMT60CyclicBarrier 綆鍗曚婦渚?/title><link>http://www.tkk7.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.tkk7.com/sunjavaer/archive/2017/07/13/432663.html</guid><wfw:comment>http://www.tkk7.com/sunjavaer/comments/432663.html</wfw:comment><comments>http://www.tkk7.com/sunjavaer/archive/2017/07/13/432663.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/sunjavaer/comments/commentRss/432663.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/sunjavaer/services/trackbacks/432663.html</trackback:ping><description><![CDATA[涓鍙ヨ瘽瑙i噴錛氶澶噡~~寮濮?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.tkk7.com/sunjavaer/aggbug/432663.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/sunjavaer/" target="_blank">涓戠敺</a> 2017-07-13 11:39 <a href="http://www.tkk7.com/sunjavaer/archive/2017/07/13/432663.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>CountDownLatch 綆鍗曚婦渚?/title><link>http://www.tkk7.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.tkk7.com/sunjavaer/archive/2017/07/13/432662.html</guid><wfw:comment>http://www.tkk7.com/sunjavaer/comments/432662.html</wfw:comment><comments>http://www.tkk7.com/sunjavaer/archive/2017/07/13/432662.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/sunjavaer/comments/commentRss/432662.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/sunjavaer/services/trackbacks/432662.html</trackback:ping><description><![CDATA[涓鍙ヨ瘽瑙i噴錛氫富綰跨▼闃誨錛屽叾浠栫嚎紼嬪畬鎴愬悗錛屼富綰跨▼琚敜閱掑悗緇х畫鎵ц<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.tkk7.com/sunjavaer/aggbug/432662.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/sunjavaer/" target="_blank">涓戠敺</a> 2017-07-13 11:18 <a href="http://www.tkk7.com/sunjavaer/archive/2017/07/13/432662.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[杞創]jasperreport鍙互鐢–ollection鍋氫負鏁版嵁婧?/title><link>http://www.tkk7.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.tkk7.com/sunjavaer/archive/2005/12/11/23371.html</guid><wfw:comment>http://www.tkk7.com/sunjavaer/comments/23371.html</wfw:comment><comments>http://www.tkk7.com/sunjavaer/archive/2005/12/11/23371.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/sunjavaer/comments/commentRss/23371.html</wfw:commentRss><trackback:ping>http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">浠eportFile鏂瑰紡 <BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">37</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">57</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">59</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">61</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">63</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>reportFile, <BR></SPAN><SPAN style="COLOR: #008080">66</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>parameters, <BR></SPAN><SPAN style="COLOR: #008080">67</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>ds); <BR></SPAN><SPAN style="COLOR: #008080">68</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">77</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">84</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">90</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">91</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.com/images/OutliningIndicators/None.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080">93</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.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.tkk7.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">95</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top> </SPAN></SPAN></DIV><BR><BR>jasperreport鍙互鐢–ollection鍋氫負鏁版嵁婧愶紝榪欑鏂瑰紡姣旂敤Connection鏂瑰紡鏇翠負鐏墊椿鏂逛究 <BR><IMG height=16 src="http://sgsoft.cnblogs.com/Images/OutliningIndicators/None.gif" width=11 align=top></SPAN> <img src ="http://www.tkk7.com/sunjavaer/aggbug/23371.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/sunjavaer/" target="_blank">涓戠敺</a> 2005-12-11 18:12 <a href="http://www.tkk7.com/sunjavaer/archive/2005/12/11/23371.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[杞笘]瀛︿範Reflectionhttp://www.tkk7.com/sunjavaer/archive/2005/08/07/9497.html涓戠敺涓戠敺Sat, 06 Aug 2005 17:02:00 GMThttp://www.tkk7.com/sunjavaer/archive/2005/08/07/9497.htmlhttp://www.tkk7.com/sunjavaer/comments/9497.htmlhttp://www.tkk7.com/sunjavaer/archive/2005/08/07/9497.html#Feedback0http://www.tkk7.com/sunjavaer/comments/commentRss/9497.htmlhttp://www.tkk7.com/sunjavaer/services/trackbacks/9497.htmlReflection 鏄?Java 紼嬪簭寮鍙戣璦鐨勭壒寰佷箣涓錛屽畠鍏佽榪愯涓殑 Java 紼嬪簭瀵硅嚜韜繘琛屾鏌ワ紝鎴栬呰鈥滆嚜瀹♀濓紝騫惰兘鐩存帴鎿嶄綔紼嬪簭鐨勫唴閮ㄥ睘鎬с備緥濡傦紝浣跨敤瀹冭兘鑾峰緱 Java 綾諱腑鍚勬垚鍛樼殑鍚嶇О騫舵樉紺哄嚭鏉ャ?/DIV>
Java 鐨勮繖涓鑳藉姏鍦ㄥ疄闄呭簲鐢ㄤ腑涔熻鐢ㄥ緱涓嶆槸寰堝錛屼絾鏄湪鍏跺畠鐨勭▼搴忚璁¤璦涓牴鏈氨涓嶅瓨鍦ㄨ繖涓鐗規с備緥濡傦紝Pascal銆丆 鎴栬?C++ 涓氨娌℃湁鍔炴硶鍦ㄧ▼搴忎腑鑾峰緱鍑芥暟瀹氫箟鐩稿叧鐨勪俊鎭?/DIV>
JavaBean 鏄?reflection 鐨勫疄闄呭簲鐢ㄤ箣涓錛屽畠鑳借涓浜涘伐鍏峰彲瑙嗗寲鐨勬搷浣滆蔣浠剁粍浠躲傝繖浜涘伐鍏烽氳繃 reflection 鍔ㄦ佺殑杞藉叆騫跺彇寰?Java 緇勪歡(綾? 鐨勫睘鎬с?/DIV>
 
1. 涓涓畝鍗曠殑渚嬪瓙
鑰冭檻涓嬮潰榪欎釜綆鍗曠殑渚嬪瓙錛岃鎴戜滑鐪嬬湅 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
瀹冪殑緇撴灉杈撳嚭涓猴細
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)
榪欐牱灝卞垪鍑轟簡java.util.Stack 綾葷殑鍚勬柟娉曞悕浠ュ強瀹冧滑鐨勯檺鍒剁鍜岃繑鍥炵被鍨嬨?/DIV>
榪欎釜紼嬪簭浣跨敤 Class.forName 杞藉叆鎸囧畾鐨勭被錛岀劧鍚庤皟鐢?getDeclaredMethods 鏉ヨ幏鍙栬繖涓被涓畾涔変簡鐨勬柟娉曞垪琛ㄣ俲ava.lang.reflect.Methods 鏄敤鏉ユ弿榪版煇涓被涓崟涓柟娉曠殑涓涓被銆?/DIV>
2.寮濮嬩嬌鐢?Reflection
鐢ㄤ簬 reflection 鐨勭被錛屽 Method錛屽彲浠ュ湪 java.lang.relfect 鍖呬腑鎵懼埌銆備嬌鐢ㄨ繖浜涚被鐨勬椂鍊欏繀欏昏閬靛驚涓変釜姝ラ錛氱涓姝ユ槸鑾峰緱浣犳兂鎿嶄綔鐨勭被鐨?java.lang.Class 瀵硅薄銆傚湪榪愯涓殑 Java 紼嬪簭涓紝鐢?java.lang.Class 綾繪潵鎻忚堪綾誨拰鎺ュ彛絳夈?/DIV>
涓嬮潰灝辨槸鑾峰緱涓涓?Class 瀵硅薄鐨勬柟娉曚箣涓錛?/DIV>
Class c = Class.forName("java.lang.String");
榪欐潯璇彞寰楀埌涓涓?String 綾葷殑綾誨璞°傝繕鏈夊彟涓縐嶆柟娉曪紝濡備笅闈㈢殑璇彞錛?/DIV>
Class c = int.class;
鎴栬?/DIV>
Class c = Integer.TYPE;
瀹冧滑鍙幏寰楀熀鏈被鍨嬬殑綾諱俊鎭傚叾涓悗涓縐嶆柟娉曚腑璁塊棶鐨勬槸鍩烘湰綾誨瀷鐨勫皝瑁呯被 (濡?Integer) 涓鍏堝畾涔夊ソ鐨?TYPE 瀛楁銆?/DIV>
絎簩姝ユ槸璋冪敤璇稿 getDeclaredMethods 鐨勬柟娉曪紝浠ュ彇寰楄綾諱腑瀹氫箟鐨勬墍鏈夋柟娉曠殑鍒楄〃銆?/DIV>
涓鏃﹀彇寰楄繖涓俊鎭紝灝卞彲浠ヨ繘琛岀涓夋浜嗏斺斾嬌鐢?reflection API 鏉ユ搷浣滆繖浜涗俊鎭紝濡備笅闈㈣繖孌典唬鐮侊細
Class c = Class.forName("java.lang.String");
Method m[] = c.getDeclaredMethods();
System.out.println(m[0].toString());
瀹冨皢浠ユ枃鏈柟寮忔墦鍗板嚭 String 涓畾涔夌殑絎竴涓柟娉曠殑鍘熷瀷銆?/DIV>
鍦ㄤ笅闈㈢殑渚嬪瓙涓紝榪欎笁涓楠ゅ皢涓轟嬌鐢?reflection 澶勭悊鐗規畩搴旂敤紼嬪簭鎻愪緵渚嬭瘉銆?/DIV>
妯℃嫙 instanceof 鎿嶄綔絎?/DIV>
寰楀埌綾諱俊鎭箣鍚庯紝閫氬父涓嬩竴涓楠ゅ氨鏄В鍐沖叧浜?Class 瀵硅薄鐨勪竴浜涘熀鏈殑闂銆備緥濡傦紝Class.isInstance 鏂規硶鍙互鐢ㄤ簬妯℃嫙 instanceof 鎿嶄綔絎︼細
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 綾葷殑 Class 瀵硅薄錛岀劧鍚庢鏌ヤ竴浜涘璞℃槸鍚︽槸 A 鐨勫疄渚嬨侷nteger(37) 涓嶆槸錛屼絾 new A() 鏄?/DIV>
3.鎵懼嚭綾葷殑鏂規硶
鎵懼嚭涓涓被涓畾涔変簡浜涗粈涔堟柟娉曪紝榪欐槸涓涓潪甯告湁浠峰間篃闈炲父鍩虹鐨?reflection 鐢ㄦ硶銆備笅闈㈢殑浠g爜灝卞疄鐜頒簡榪欎竴鐢ㄦ硶錛?/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);
       }
   }
}
榪欎釜紼嬪簭棣栧厛鍙栧緱 method1 綾葷殑鎻忚堪錛岀劧鍚庤皟鐢?getDeclaredMethods 鏉ヨ幏鍙栦竴緋誨垪鐨?Method 瀵硅薄錛屽畠浠垎鍒弿榪頒簡瀹氫箟鍦ㄧ被涓殑姣忎竴涓柟娉曪紝鍖呮嫭 public 鏂規硶銆乸rotected 鏂規硶銆乸ackage 鏂規硶鍜?private 鏂規硶絳夈傚鏋滀綘鍦ㄧ▼搴忎腑浣跨敤 getMethods 鏉ヤ唬鏇?getDeclaredMethods錛屼綘榪樿兘鑾峰緱緇ф壙鏉ョ殑鍚勪釜鏂規硶鐨勪俊鎭?/DIV>
鍙栧緱浜?Method 瀵硅薄鍒楄〃涔嬪悗錛岃鏄劇ず榪欎簺鏂規硶鐨勫弬鏁扮被鍨嬨佸紓甯哥被鍨嬪拰榪斿洖鍊肩被鍨嬬瓑灝變笉闅句簡銆傝繖浜涚被鍨嬫槸鍩烘湰綾誨瀷榪樻槸綾葷被鍨嬶紝閮藉彲浠ョ敱鎻忚堪綾葷殑瀵硅薄鎸夐『搴忕粰鍑恒?/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.鑾峰彇鏋勯犲櫒淇℃伅
鑾峰彇綾繪瀯閫犲櫒鐨勭敤娉曚笌涓婅堪鑾峰彇鏂規硶鐨勭敤娉曠被浼鹼紝濡傦細
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);
       }
   }
}
榪欎釜渚嬪瓙涓病鑳借幏寰楄繑鍥炵被鍨嬬殑鐩稿叧淇℃伅錛岄偅鏄洜涓烘瀯閫犲櫒娌℃湁榪斿洖綾誨瀷銆?/DIV>
榪欎釜紼嬪簭榪愯鐨勭粨鏋滄槸錛?/DIV>
name = constructor1
decl class = class constructor1
-----
name = constructor1
decl class = class constructor1
param #0 int
param #1 double
-----
5.鑾峰彇綾葷殑瀛楁(鍩?
鎵懼嚭涓涓被涓畾涔変簡鍝簺鏁版嵁瀛楁涔熸槸鍙兘鐨勶紝涓嬮潰鐨勪唬鐮佸氨鍦ㄥ共榪欎釜浜嬫儏錛?/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);
       }
   }
}
榪欎釜渚嬪瓙鍜屽墠闈㈤偅涓緥瀛愰潪甯哥浉浼箋備緥涓嬌鐢ㄤ簡涓涓柊涓滆タ Modifier錛屽畠涔熸槸涓涓?reflection 綾伙紝鐢ㄦ潵鎻忚堪瀛楁鎴愬憳鐨勪慨楗拌錛屽鈥減rivate int鈥濄傝繖浜涗慨楗拌鑷韓鐢辨暣鏁版弿榪幫紝鑰屼笖浣跨敤 Modifier.toString 鏉ヨ繑鍥炰互鈥滃畼鏂光濋『搴忔帓鍒楃殑瀛楃涓叉弿榪?(濡傗渟tatic鈥濆湪鈥渇inal鈥濅箣鍓?銆傝繖涓▼搴忕殑杈撳嚭鏄細
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 =
-----
鍜岃幏鍙栨柟娉曠殑鎯呭喌涓涓嬶紝鑾峰彇瀛楁鐨勬椂鍊欎篃鍙互鍙彇寰楀湪褰撳墠綾諱腑鐢蟲槑浜嗙殑瀛楁淇℃伅 (getDeclaredFields)錛屾垨鑰呬篃鍙互鍙栧緱鐖剁被涓畾涔夌殑瀛楁 (getFields) 銆?/DIV>

6.鏍規嵁鏂規硶鐨勫悕縐版潵鎵ц鏂規硶
鏂囨湰鍒拌繖閲岋紝鎵涓劇殑渚嬪瓙鏃犱竴渚嬪閮戒笌濡備綍鑾峰彇綾葷殑淇℃伅鏈夊叧銆傛垜浠篃鍙互鐢?reflection 鏉ュ仛涓浜涘叾瀹冪殑浜嬫儏錛屾瘮濡傛墽琛屼竴涓寚瀹氫簡鍚嶇О鐨勬柟娉曘備笅闈㈢殑紺轟緥婕旂ず浜嗚繖涓鎿嶄綔錛?/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);
       }
   }
}
鍋囧涓涓▼搴忓湪鎵ц鐨勬煇澶勭殑鏃跺欐墠鐭ラ亾闇瑕佹墽琛屾煇涓柟娉曪紝榪欎釜鏂規硶鐨勫悕縐版槸鍦ㄧ▼搴忕殑榪愯榪囩▼涓寚瀹氱殑 (渚嬪錛孞avaBean 寮鍙戠幆澧冧腑灝變細鍋氳繖鏍風殑浜?錛岄偅涔堜笂闈㈢殑紼嬪簭婕旂ず浜嗗浣曞仛鍒般?/DIV>
涓婁緥涓紝getMethod 鐢ㄤ簬鏌ユ壘涓涓叿鏈変袱涓暣鍨嬪弬鏁頒笖鍚嶄負 add 鐨勬柟娉曘傛壘鍒拌鏂規硶騫跺垱寤轟簡鐩稿簲鐨?Method 瀵硅薄涔嬪悗錛屽湪姝g‘鐨勫璞″疄渚嬩腑鎵ц瀹冦傛墽琛岃鏂規硶鐨勬椂鍊欙紝闇瑕佹彁渚涗竴涓弬鏁板垪琛紝榪欏湪涓婁緥涓槸鍒嗗埆鍖呰浜嗘暣鏁?37 鍜?47 鐨勪袱涓?Integer 瀵硅薄銆傛墽琛屾柟娉曠殑榪斿洖鐨勫悓鏍鋒槸涓涓?Integer 瀵硅薄錛屽畠灝佽浜嗚繑鍥炲?84銆?/DIV>
7.鍒涘緩鏂扮殑瀵硅薄
瀵逛簬鏋勯犲櫒錛屽垯涓嶈兘鍍忔墽琛屾柟娉曢偅鏍瘋繘琛岋紝鍥犱負鎵ц涓涓瀯閫犲櫒灝辨剰鍛崇潃鍒涘緩浜嗕竴涓柊鐨勫璞?(鍑嗙‘鐨勮錛屽垱寤轟竴涓璞$殑榪囩▼鍖呮嫭鍒嗛厤鍐呭瓨鍜屾瀯閫犲璞?銆傛墍浠ワ紝涓庝笂渚嬫渶鐩鎬技鐨勪緥瀛愬涓嬶細
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);
       }
   }
}
鏍規嵁鎸囧畾鐨勫弬鏁扮被鍨嬫壘鍒扮浉搴旂殑鏋勯犲嚱鏁板茍鎵ц瀹冿紝浠ュ垱寤轟竴涓柊鐨勫璞″疄渚嬨備嬌鐢ㄨ繖縐嶆柟娉曞彲浠ュ湪紼嬪簭榪愯鏃跺姩鎬佸湴鍒涘緩瀵硅薄錛岃屼笉鏄湪緙栬瘧鐨勬椂鍊欏垱寤哄璞★紝榪欎竴鐐歸潪甯告湁浠峰箋?/DIV>
8.鏀瑰彉瀛楁(鍩?鐨勫?/DIV>
reflection 鐨勮繕鏈変竴涓敤澶勫氨鏄敼鍙樺璞℃暟鎹瓧孌電殑鍊箋俽eflection 鍙互浠庢鍦ㄨ繍琛岀殑紼嬪簭涓牴鎹悕縐版壘鍒板璞$殑瀛楁騫舵敼鍙樺畠錛屼笅闈㈢殑渚嬪瓙鍙互璇存槑榪欎竴鐐癸細
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);
       }
   }
}
榪欎釜渚嬪瓙涓紝瀛楁 d 鐨勫艱鍙樹負浜?12.34銆?/DIV>
9.浣跨敤鏁扮粍
鏈枃浠嬬粛鐨?reflection 鐨勬渶鍚庝竴縐嶇敤娉曟槸鍒涘緩鐨勬搷浣滄暟緇勩傛暟緇勫湪 Java 璇█涓槸涓縐嶇壒孌婄殑綾葷被鍨嬶紝涓涓暟緇勭殑寮曠敤鍙互璧嬬粰 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 鏁扮粍錛屼負絎?5 涓綅緗殑瀛楃涓茶祴浜嗗鹼紝鏈鍚庡皢榪欎釜瀛楃涓蹭粠鏁扮粍涓彇寰楀茍鎵撳嵃浜嗗嚭鏉ャ?/DIV>
涓嬮潰榪欐浠g爜鎻愪緵浜嗕竴涓洿澶嶆潅鐨勪緥瀛愶細
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 鐨勬暣鍨嬫暟緇勶紝騫朵負澶勪簬 [3][5][10] 鐨勫厓绱犺祴浜嗗間負 37銆傛敞鎰忥紝澶氱淮鏁扮粍瀹為檯涓婂氨鏄暟緇勭殑鏁扮粍錛屼緥濡傦紝絎竴涓?Array.get 涔嬪悗錛宎rrobj 鏄竴涓?10 x 15 鐨勬暟緇勩傝繘鑰屽彇寰楀叾涓殑涓涓厓绱狅紝鍗抽暱搴︿負 15 鐨勬暟緇勶紝騫朵嬌鐢?Array.setInt 涓哄畠鐨勭 10 涓厓绱犺祴鍊箋?/DIV>
娉ㄦ剰鍒涘緩鏁扮粍鏃剁殑綾誨瀷鏄姩鎬佺殑錛屽湪緙栬瘧鏃跺茍涓嶇煡閬撳叾綾誨瀷銆?BR>


涓戠敺 2005-08-07 01:02 鍙戣〃璇勮
]]>綆鍗曞簲鐢ㄦ棩鏈熺被http://www.tkk7.com/sunjavaer/archive/2005/08/05/9440.html涓戠敺涓戠敺Fri, 05 Aug 2005 15:31:00 GMThttp://www.tkk7.com/sunjavaer/archive/2005/08/05/9440.htmlhttp://www.tkk7.com/sunjavaer/comments/9440.htmlhttp://www.tkk7.com/sunjavaer/archive/2005/08/05/9440.html#Feedback0http://www.tkk7.com/sunjavaer/comments/commentRss/9440.htmlhttp://www.tkk7.com/sunjavaer/services/trackbacks/9440.html聽聽 鐢ㄥ埌java.text.SimpleDateFormat錛屽叾涓弬鏁板涓嬶細
聽聽聽ss錛氱
聽聽聽mm錛氬垎
聽聽聽hh錛氬皬鏃?BR>聽聽聽EEEE錛氭槦鏈?BR>聽聽聽MMMM錛氭湀浠?BR>聽聽 dd錛氭棩鏈?BR>聽聽 yyyy錛氬勾浠?BR>
聽聽聽聽聽聽聽聽Date聽d聽=new聽Date();
聽聽聽聽聽聽聽聽SimpleDateFormat聽sdf聽
=new聽SimpleDateFormat("ss-mm-hh-EEEE-MMMM-dd-yyyy");
聽聽聽聽聽聽聽聽System.
out.println(sdf.format(d));

榪愯緇撴灉
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));
聽聽聽聽聽聽聽聽聽聽 //杈撳嚭緇撴灉聽聽聽聽聽 05-7-22 涓嬪崍11:47


聽聽聽聽聽聽聽聽聽聽 DateFormat mediumDateFormat = DateFormat.getDateTimeInstance(聽DateFormat.MEDIUM,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 DateFormat.MEDIUM);聽
聽聽聽聽聽聽聽聽聽聽 System.out.println聽(mediumDateFormat.format(date));
聽聽聽聽聽聽聽聽聽聽 //杈撳嚭緇撴灉聽聽聽聽聽聽 2005-7-22 23:48:11


聽聽聽聽聽聽聽聽聽聽 DateFormat longDateFormat =聽DateFormat.getDateTimeInstance(聽DateFormat.LONG,聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 DateFormat.LONG);
聽聽聽聽聽聽聽聽聽聽 System.out.println(longDateFormat.format(date));
聽聽聽聽聽聽聽聽聽聽 //杈撳嚭緇撴灉聽聽聽聽聽 2005騫?鏈?2鏃?涓嬪崍11鏃?8鍒?5縐?/SPAN>


聽聽聽聽聽聽聽聽聽聽 DateFormat fullDateFormat = DateFormat.getDateTimeInstance( DateFormat.FULL,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 DateFormat.FULL);
聽聽聽聽聽聽聽聽聽聽 System.out.println聽(fullDateFormat.format(date));
聽聽聽聽聽聽聽聽聽聽 //杈撳嚭緇撴灉聽聽聽聽聽 Saturday, September 29, 2001 8:44:45 PM EDT



涓戠敺 2005-08-05 23:31 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 国产成人高清精品免费鸭子 | 亚洲粉嫩美白在线| 国产精品免费福利久久| 亚洲日韩中文无码久久| 国产在线播放线91免费| 国产成人亚洲综合无码精品| 久久久久女教师免费一区| 久久久久亚洲?V成人无码| 国产特黄特色的大片观看免费视频| 国产成人精品日本亚洲专区 | 色妞www精品视频免费看| 国产性生交xxxxx免费| 色屁屁在线观看视频免费| 亚洲精品线路一在线观看| 巨胸喷奶水www永久免费| 亚洲韩国—中文字幕| 国产精品久久免费| 亚洲永久网址在线观看| 免费一级黄色毛片| 国产乱子伦精品免费视频| 亚洲av中文无码乱人伦在线咪咕| 午夜视频在线免费观看| 亚洲偷偷自拍高清| 国产又粗又长又硬免费视频| 日韩在线一区二区三区免费视频 | 人妻免费久久久久久久了| 亚洲精品无码专区在线在线播放 | 亚洲精品无播放器在线播放| 亚洲Av无码乱码在线观看性色| 一个人看的免费视频www在线高清动漫 | 啦啦啦在线免费视频| 国产日韩精品无码区免费专区国产| 亚洲国产日韩在线视频| 国产香蕉免费精品视频| 羞羞视频免费观看| 无码乱人伦一区二区亚洲| 在线观看视频免费国语| 91免费在线视频| 最新亚洲卡一卡二卡三新区| 国产亚洲婷婷香蕉久久精品| 97在线观免费视频观看 |