??xml version="1.0" encoding="utf-8" standalone="yes"?>yiren22亚洲综合伊人22,日本视频精品一区,四虎影院在线域名免费观看http://www.aygfsteel.com/feng0801/zh-cnTue, 17 Jun 2025 05:42:26 GMTTue, 17 Jun 2025 05:42:26 GMT60HttpClient 时异常含义http://www.aygfsteel.com/feng0801/archive/2018/04/20/433176.htmlForMeBlogForMeBlogFri, 20 Apr 2018 06:36:00 GMThttp://www.aygfsteel.com/feng0801/archive/2018/04/20/433176.htmlhttp://www.aygfsteel.com/feng0801/comments/433176.htmlhttp://www.aygfsteel.com/feng0801/archive/2018/04/20/433176.html#Feedback0http://www.aygfsteel.com/feng0801/comments/commentRss/433176.htmlhttp://www.aygfsteel.com/feng0801/services/trackbacks/433176.html

关于HTTPh时字段定义

一、ConnectionRequestTimeout 时
HttpClient 使用q接池来理q接Q这个时间是从连接池获取q接的超时时_(d)可以联想从数据库q接池获取数据库q接?/div>

二、ConnectTimeout 时
建立q接时Q客L(fng)和服务器间徏立连接进行的三次握手完成的时?/div>

三、SocketTimeout 时
数据传输q程中数据包之间间隔的最大时_(d)Http响应报文可能有多个小报文l成Q?/div>
如果传输报文的间隔时间超q设|这个时_(d)?x)?java.net.SocketTimeoutException: Read timed out 异常?/div>


ForMeBlog 2018-04-20 14:36 发表评论
]]>Eclipse 常用快捷键汇?/title><link>http://www.aygfsteel.com/feng0801/archive/2015/11/20/428306.html</link><dc:creator>ForMeBlog</dc:creator><author>ForMeBlog</author><pubDate>Fri, 20 Nov 2015 08:36:00 GMT</pubDate><guid>http://www.aygfsteel.com/feng0801/archive/2015/11/20/428306.html</guid><wfw:comment>http://www.aygfsteel.com/feng0801/comments/428306.html</wfw:comment><comments>http://www.aygfsteel.com/feng0801/archive/2015/11/20/428306.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/feng0801/comments/commentRss/428306.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/feng0801/services/trackbacks/428306.html</trackback:ping><description><![CDATA[<div><span style="color: #ff6600;">提示Q编写Eclipse常用快捷键写成文档,主要是ؓ(f)了自q(zhn)一下这些快捷键Q方便以后查扑֒~程中用!</span></div> <div>一、编辑类快捷?/div> <div>1、Ctrl + 1 快速修复,可以解决很多问题Q例如importcRtry catch包围{?/div> <div>2、Ctrl + Shift + F 格式化当前代码?/div> <div>3、Ctrl + Shift + M dcȝimport引入?/div> <div>4、Ctrl + Shift + M l织cȝimport引入Q既有Ctrl + Shift + M 的作用,又可以帮你去除没有用的引入?/div> <div>5、Ctrl + Y 重做与Ctrl + Z 相反的作用?/div> <div>6、Alt + / 内容辅助</div> <div>7、Ctrl + D 删除当前行或者选中的多?/div> <div>8、Alt + Down 当前行和下面一行交换位|?/div> <div>9、Alt + Up 当前行和上面一行交换位|?/div> <div>10、Shift + Enter 在当前行的下一行插入空?/div> <div>11、Ctrl + / 注释当前行,再次按则取消注释</div> <div>二、选择快捷?/div> <div>1、Alt + Shift + Up 选择装元素</div> <div>2、Alt + Shift + Left 选择上一个元?/div> <div>3、Alt + Shift + Right选择下一个元?/div> <div>4、Shift + Left 从光标处开始往左选择字符?/div> <div>5、Shift + Right 从光标处开始往右选择字符?/div> <div>6、Ctrl + Shift + Left 选中光标左边的单?/div> <div>7、Ctrl + Shift + Right 选中光标双的单?/div> <div> </div> <div>三、移动快捷键</div> <div>1、Ctrl + Left 光标Ud左边单词的开_(d)</div> <div>2、Ctrl + Right 光标Ud双单词的末?/div> <div> </div> <div>四、搜索快捷键</div> <div>1、Ctrl + K 参照选中的文字快速定位到下一个,如果没有选中文字则搜索上一ơ用搜索的文字?/div> <div>2、Ctrl + Shift + K 参照选中的文字快速定位到上一个?/div> <div>3、Ctrl + J 正向增量查找Q按下这个快捷键后,你所输入的每个字母编辑器都提供快速匹配到某个单词Q如果没有在状态栏中显C没有找刎ͼ退个模式按ESC键?/div> <div>4、Ctrl + Shift + J 反向增量查找</div> <div>5、Ctrl + Shift + U 列出所有包含字W串的行</div> <div>6、Ctrl + G 工作Z的声?/div> <div>7、Ctrl + Shift + G 工作Z的引?/div> <div> </div> <div>五、导航快捷键</div> <div>1、Ctrl + Shift + T 搜烦c?/div> <div>2、Ctrl + Shift + R 搜烦工程中的文g</div> <div>3、Ctrl + E 快速显C当前编辑区的下拉列?/div> <div>4、F4 打开cd层次l构</div> <div>5、F3 跌{到声明处</div> <div>6、Alt + Left 前一个编辑页?/div> <div>7、Alt + Right 下一个编辑页?/div> <div>8、Ctrl + PageUp/PageDown在编辑器中,切换已经打开的文?/div> <div> </div> <div>六、调试快捷键</div> <div>1、F5 单步跛_</div> <div>2、F6 单步跌</div> <div>3、F7 单步q回</div> <div>4、F8 l箋</div> <div>5、Ctrl + Shift + D 昄变量的?/div> <div>6、Ctrl + shift + B 在当前行讄或者去掉断?/div> <div>7、Ctrl + R q行臌Q比较好用可以省好多的断?/div> <div> </div> <div>七、重构快捷键</div> <div>1、Alt + Shift + R 重命名类名、方法名、属性(变量Q名?/div> <div>2、Alt + Shift + M 把一D函数内的代码抽取成Ҏ(gu)Q这是重构里面最常用的方法之一Q特别是对于一大坨代码很有用?/div> <div>3、Alt + Shift + C 修改函数l构Q比较实用有N个函数调用了q个Ҏ(gu)修改一ơ就行了?/div> <div>4、Alt + Shift + L 抽取本地变量Q可以直接把一些魔法数字和字符串抽取成一个变量,其是多用的时候?/div> <div>5、Alt + Shift + F 把Class中的局部变量变为全局变量</div> <div>6、Alt + Shift + I 合ƈ变量Q将创徏?/div> <div>7、Alt + Shift + Z 撤销重构</div> <div> </div> <div>八、其他快捷键</div> <div>1、Alt + Enter 昄当前选择资源的属性,在windows下查看文件的属性就是这个快捷键Q通常可以用来查看文g在windows中的实际路径?/div> <div>2、Ctrl + Up文本~辑器向上滚?/div> <div>3、Ctrl + Down 文本~辑器向下滚?/div> <div>4、Ctrl + M 最大化当前的Edit或者ViewQ再按则~小</div> <div>5、Ctrl + O 快速显COutline</div> <div>6、Ctrl + T 快速显C当前类的承结构,选中接口Ҏ(gu)按下q快捷可以蟩转到实现c,在项目DAO中经常用?/div> <div>7、Ctrl + W 关闭当前Editer</div> <div>8、Ctrl + L 文本~辑器{臌</div> <div>9、F2 昄工具提示描述Q选择cL者变量按下该键会(x)有提C出?/div><img src ="http://www.aygfsteel.com/feng0801/aggbug/428306.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/feng0801/" target="_blank">ForMeBlog</a> 2015-11-20 16:36 <a href="http://www.aygfsteel.com/feng0801/archive/2015/11/20/428306.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Z么要两次调用encodeURI来解决ؕ码问?/title><link>http://www.aygfsteel.com/feng0801/archive/2015/08/18/426866.html</link><dc:creator>ForMeBlog</dc:creator><author>ForMeBlog</author><pubDate>Tue, 18 Aug 2015 03:20:00 GMT</pubDate><guid>http://www.aygfsteel.com/feng0801/archive/2015/08/18/426866.html</guid><wfw:comment>http://www.aygfsteel.com/feng0801/comments/426866.html</wfw:comment><comments>http://www.aygfsteel.com/feng0801/archive/2015/08/18/426866.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/feng0801/comments/commentRss/426866.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/feng0801/services/trackbacks/426866.html</trackback:ping><description><![CDATA[<p style="white-space: normal; word-spacing: 0px; text-transform: none; color: rgb(85,85,85); padding-bottom: 0px; padding-top: 0px; font: 15px/35px 'microsoft yahei'; padding-left: 0px; margin: 0px; widows: 1; letter-spacing: normal; padding-right: 0px; background-color: rgb(255,255,255); text-indent: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Courier New'"><span style="font-family: 'Courier New'; background-color: rgb(245,245,245)">今天遇到调用encodeURL调用二次的疑问,虽然之前知道要调用二ơ,但是具体不是太清楚里面具体的q行q程Q这是{载的q个写的比较详细Q把整个q行q程详细解读了一下,非常不错所以{载过了供其他人分享?br />.encodeURL函数主要是来对URI来做转码Q它默认是采用的UTF-8的编?</span><br /><span style="font-family: 'Courier New'; background-color: rgb(245,245,245)">. UTF-8~码的格?一个汉字来三个字节构成Q每一个字节会(x)转换?6q制的编码,同时d??</span><br /></span></p> <p style="white-space: normal; word-spacing: 0px; text-transform: none; color: rgb(85,85,85); padding-bottom: 0px; padding-top: 0px; font: 15px/35px 'microsoft yahei'; padding-left: 0px; margin: 0px; widows: 1; letter-spacing: normal; padding-right: 0px; background-color: rgb(255,255,255); text-indent: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Courier New'">假设面端输入的中文是一?#8220;?#8221;Q按照下面步骤进行解?/span></p> <p style="white-space: normal; word-spacing: 0px; text-transform: none; color: rgb(85,85,85); padding-bottom: 0px; padding-top: 0px; font: 15px/35px 'microsoft yahei'; padding-left: 0px; margin: 0px; widows: 1; letter-spacing: normal; padding-right: 0px; background-color: rgb(255,255,255); text-indent: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(128,0,0)">1</span><span style="font-family: 'Courier New'">.W一ơencodeURIQ?span style="color: rgb(255,0,255); line-height: 1.5">按照utf</span></span><span style="font-family: 'Courier New'; color: rgb(255,0,255)">-8方式获取字节数组变成[-28,-72-83]Q对字节码数l进行遍历,把每个字节{化成对应?6q制敎ͼq样变成了[E4,B8,AD],最后变成[%E4,%B8,%AD]  此时已经没有了多字节字符Q全部是单字节字W?/span></p> <p style="white-space: normal; word-spacing: 0px; text-transform: none; color: rgb(85,85,85); padding-bottom: 0px; padding-top: 0px; font: 15px/35px 'microsoft yahei'; padding-left: 0px; margin: 0px; widows: 1; letter-spacing: normal; padding-right: 0px; background-color: rgb(255,255,255); text-indent: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Courier New'"><span><strong>2?span style="font-family: 'Courier New'">W二ơencodeURIQ进行编码,?x)?看成一个{义字W,q不~码%以后字符Q会(x)?~码?25.把数l最后变?/span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">[</span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">%25E4,%25B8,%25AD</span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">]</span><span style="font-family: 'Courier New'">然后把处理后的数据</span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">[</span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">%25E4,%25B8,%25AD</span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">]</span><span style="font-family: 'Courier New'">发往服务器端Q?br />当应用服务器调用getParameterҎ(gu)QgetParameterҎ(gu)?x)去向应用服务器h参数<br />应用服务器最初获得的是发送来?/span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">[</span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">%25E4,%25B8,%25AD</span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">]</span><span style="font-family: 'Courier New'">Q应用服务器?x)对q个数据q行URLdecode操作Q应用服务器q行解码的这一ơ,不管是按照UTF-8Q还是GBKQ还是ISO-8859Q?都能得到</span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">[</span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">%E4,%B8,%AD</span><span style="font-family: 'Courier New'; color: rgb(255,0,0)">]</span><span style="font-family: 'Courier New'">Q因为都?x)?25解析?.q把q个D回给getParameterҎ(gu)</span></strong></span></span></p> <p style="white-space: normal; word-spacing: 0px; text-transform: none; color: rgb(85,85,85); padding-bottom: 0px; padding-top: 0px; font: 15px/35px 'microsoft yahei'; padding-left: 0px; margin: 0px; widows: 1; letter-spacing: normal; padding-right: 0px; background-color: rgb(255,255,255); text-indent: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Courier New'"><span><strong>3\、再用UTF-8解码一ơ,得??了?/strong></span></span></p> <p style="white-space: normal; word-spacing: 0px; text-transform: none; color: rgb(85,85,85); padding-bottom: 0px; padding-top: 0px; font: 15px/35px 'microsoft yahei'; padding-left: 0px; margin: 0px; widows: 1; letter-spacing: normal; padding-right: 0px; background-color: rgb(255,255,255); text-indent: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Courier New'"><span><strong>x看,如果不编码两ơ,当服务器自动解码的时候,假如是按照ISO-8859去解码UTF-8~码的东西,是?x)出Cؕ码?/strong></span></span></p> <p style="white-space: normal; word-spacing: 0px; text-transform: none; color: rgb(85,85,85); padding-bottom: 0px; padding-top: 0px; font: 15px/35px 'microsoft yahei'; padding-left: 0px; margin: 0px; widows: 1; letter-spacing: normal; padding-right: 0px; background-color: rgb(255,255,255); text-indent: 0px; -webkit-text-stroke-width: 0px">JS:</p> <div id="wmqeeuq" class="dp-highlighter bg_sql" style="overflow: hidden; border-top-color: rgb(204,204,204); width: 938px; white-space: normal; word-spacing: 0px; text-transform: none; border-left-color: rgb(204,204,204); color: rgb(85,85,85); border-bottom-color: rgb(204,204,204); text-align: left; padding-top: 1px; font: 12px/35px Consolas, 'Courier New', Courier, mono, serif; margin: 18px 0px; widows: 1; border-right-color: rgb(204,204,204); letter-spacing: normal; background-color: rgb(231,229,220); text-indent: 0px; -webkit-text-stroke-width: 0px"> <div id="wmqeeuq" class="bar" style="padding-left: 45px"> <div id="wmqeeuq" class="tools" style="color: silver; padding-bottom: 10px; padding-top: 3px; font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif; padding-left: 10px; border-left: rgb(108,226,108) 3px solid; padding-right: 8px; background-color: rgb(248,248,248); font-stretch: normal"><strong>[sql]</strong><span id="wmqeeuq" class="Apple-converted-space"> </span><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" title="view plain" class="ViewSource" style="font-size: 9px; text-decoration: none; border-top: medium none; height: 16px; border-right: medium none; width: 16px;background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-repeat: no-repeat; border-bottom: medium none; background-position: 0% 0%; color: rgb(12,137,207); padding-bottom: 1px; padding-top: 1px; padding-left: 1px; margin: 0px 10px 0px 0px; border-left: medium none; display: inline-block; padding-right: 1px; text-indent: -2000px; background-size: initial; background-origin: initial; background-clip: initial" >view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" title="copy" class="CopyToClipboard" style="font-size: 9px; text-decoration: none; border-top: medium none; height: 16px; border-right: medium none; width: 16px;background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-repeat: no-repeat; border-bottom: medium none; background-position: 0% 0%; color: rgb(12,137,207); padding-bottom: 1px; padding-top: 1px; padding-left: 1px; margin: 0px 10px 0px 0px; border-left: medium none; display: inline-block; padding-right: 1px; text-indent: -2000px; background-size: initial; background-origin: initial; background-clip: initial" >copy</a> <div style="height: 18px; width: 18px; position: absolute; left: 417px; z-index: 99; top: 833px"><embed id="ZeroClipboardMovie_1" name="ZeroClipboardMovie_1" type="application/x-shockwave-flash" align="center" pluginspage="http://www.macromedia.com/go/getflashplayer" height="18" width="18" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" wmode="transparent" flashvars="id=1&width=18&height=18" allowfullscreen="false" allowscriptaccess="always" bgcolor="#ffffff" quality="best" menu="false" loop="false"></div></div></div> <ol class="dp-sql" style="list-style-type: decimal; border-top: medium none; border-right: medium none; border-bottom: medium none; color: rgb(92,92,92); padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px 0px 1px 45px; border-left: medium none; padding-right: 0px; background-color: rgb(255,255,255)"><li id="wmqeeuq" class="alt" style="border-top-style: none; list-style-type: decimal-leading-zero; list-style-position: outside; border-bottom-style: none; color: ; padding-bottom: 0px !important; padding-top: 0px !important; border-right-style: none; padding-left: 10px !important; margin: 0px; border-left: rgb(108,226,108) 3px solid; line-height: 18px; padding-right: 3px !important; background-color: rgb(255,255,255)"><span style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: black; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px"><span style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: black; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">document.authorityForm.</span><span id="wmqeeuq" class="keyword" style="border-top: medium none; border-right: medium none; border-bottom: medium none; font-weight: bold; color: rgb(0,102,153); padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">action</span><span style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: black; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px"> = basePath3+</span><span id="wmqeeuq" class="string" style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: blue; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">"User_viewUser.do?id="</span><span style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: black; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">+id+</span><span id="wmqeeuq" class="string" style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: blue; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">"&roleName="</span><span style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: black; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">+encodeURI(encodeURI(roleName))+</span><span id="wmqeeuq" class="string" style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: blue; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">"&roleType="</span><span style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: black; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">+roleType;  </span></span></li></ol></div> <p style="white-space: normal; word-spacing: 0px; text-transform: none; color: rgb(85,85,85); padding-bottom: 0px; padding-top: 0px; font: 15px/35px 'microsoft yahei'; padding-left: 0px; margin: 0px; widows: 1; letter-spacing: normal; padding-right: 0px; background-color: rgb(255,255,255); text-indent: 0px; -webkit-text-stroke-width: 0px"><br />JAVA后台Q?br />   </p> <div id="wmqeeuq" class="dp-highlighter bg_sql" style="overflow: hidden; border-top-color: rgb(204,204,204); width: 938px; white-space: normal; word-spacing: 0px; text-transform: none; border-left-color: rgb(204,204,204); color: rgb(85,85,85); border-bottom-color: rgb(204,204,204); text-align: left; padding-top: 1px; font: 12px/35px Consolas, 'Courier New', Courier, mono, serif; margin: 18px 0px; widows: 1; border-right-color: rgb(204,204,204); letter-spacing: normal; background-color: rgb(231,229,220); text-indent: 0px; -webkit-text-stroke-width: 0px"> <div id="wmqeeuq" class="bar" style="padding-left: 45px"> <div id="wmqeeuq" class="tools" style="color: silver; padding-bottom: 10px; padding-top: 3px; font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif; padding-left: 10px; border-left: rgb(108,226,108) 3px solid; padding-right: 8px; background-color: rgb(248,248,248); font-stretch: normal"><strong>[sql]</strong><span id="wmqeeuq" class="Apple-converted-space"> </span><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" title="view plain" class="ViewSource" style="font-size: 9px; text-decoration: none; border-top: medium none; height: 16px; border-right: medium none; width: 16px;background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-repeat: no-repeat; border-bottom: medium none; background-position: 0% 0%; color: rgb(12,137,207); padding-bottom: 1px; padding-top: 1px; padding-left: 1px; margin: 0px 10px 0px 0px; border-left: medium none; display: inline-block; padding-right: 1px; text-indent: -2000px; background-size: initial; background-origin: initial; background-clip: initial" >view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" title="copy" class="CopyToClipboard" style="font-size: 9px; text-decoration: none; border-top: medium none; height: 16px; border-right: medium none; width: 16px;background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-repeat: no-repeat; border-bottom: medium none; background-position: 0% 0%; color: rgb(12,137,207); padding-bottom: 1px; padding-top: 1px; padding-left: 1px; margin: 0px 10px 0px 0px; border-left: medium none; display: inline-block; padding-right: 1px; text-indent: -2000px; background-size: initial; background-origin: initial; background-clip: initial" >copy</a> <div style="height: 18px; width: 18px; position: absolute; left: 417px; z-index: 99; top: 1043px"><embed id="ZeroClipboardMovie_2" name="ZeroClipboardMovie_2" type="application/x-shockwave-flash" align="center" pluginspage="http://www.macromedia.com/go/getflashplayer" height="18" width="18" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" wmode="transparent" flashvars="id=2&width=18&height=18" allowfullscreen="false" allowscriptaccess="always" bgcolor="#ffffff" quality="best" menu="false" loop="false"></div></div></div> <ol class="dp-sql" style="list-style-type: decimal; border-top: medium none; border-right: medium none; border-bottom: medium none; color: rgb(92,92,92); padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px 0px 1px 45px; border-left: medium none; padding-right: 0px; background-color: rgb(255,255,255)"><li id="wmqeeuq" class="alt" style="border-top-style: none; list-style-type: decimal-leading-zero; list-style-position: outside; border-bottom-style: none; color: ; padding-bottom: 0px !important; padding-top: 0px !important; border-right-style: none; padding-left: 10px !important; margin: 0px; border-left: rgb(108,226,108) 3px solid; line-height: 18px; padding-right: 3px !important; background-color: rgb(255,255,255)"><span style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: black; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px"><span style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: black; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">roleName = java.net.URLDecoder.decode(getRequest().getParameter(</span><span id="wmqeeuq" class="string" style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: blue; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">"roleName"</span><span style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: black; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">),</span><span id="wmqeeuq" class="string" style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: blue; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">"UTF-8"</span><span style="border-top: medium none; border-right: medium none; border-bottom: medium none; color: black; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: medium none; padding-right: 0px">);  </span></span></li></ol></div><img src ="http://www.aygfsteel.com/feng0801/aggbug/426866.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/feng0801/" target="_blank">ForMeBlog</a> 2015-08-18 11:20 <a href="http://www.aygfsteel.com/feng0801/archive/2015/08/18/426866.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java基础之理解Annotationhttp://www.aygfsteel.com/feng0801/archive/2015/06/11/425636.htmlForMeBlogForMeBlogThu, 11 Jun 2015 10:06:00 GMThttp://www.aygfsteel.com/feng0801/archive/2015/06/11/425636.htmlhttp://www.aygfsteel.com/feng0801/comments/425636.htmlhttp://www.aygfsteel.com/feng0801/archive/2015/06/11/425636.html#Feedback0http://www.aygfsteel.com/feng0801/comments/commentRss/425636.htmlhttp://www.aygfsteel.com/feng0801/services/trackbacks/425636.html

 

、概?/strong>

 

 

   Annontation?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">Java5开始引入的新特征。中文名UC般叫注解。它提供了一U安全的cM注释的机Ӟ用来Q何的信息或元数据Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">metadataQ与E序元素Q类、方法、成员变量等Q进行关联?/p>

 

  更通俗的意思是为程序的元素Q类、方法、成员变量)加上更直观更明了的说明,q些说明信息是与E序的业务逻辑无关Qƈ且是供指定的工具或框架用的?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">

 

Annontation像一U修饰符一P应用于包、类型、构造方法、方法、成员变量、参数及(qing)本地变量的声明语句中?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">

 

?/span>、原?/strong>

 

  Annotation其实是一U接口。通过Java的反机制相关的API来访?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">annotation信息。相关类Q框架或工具中的c)Ҏ(gu)q些信息来决定如何用该E序元素或改变它们的行ؓ(f)?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">

 

  annotation是不?x)媄响程序代码的执行Q无?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">annotation怎么变化Q代码都始终如一地执行?/p>

 

  Java语言解释器在工作时会(x)忽略q些annotationQ因此在JVM 中这?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">annotation?#8220;不v作用”的,只能通过配套的工h能对q些annontaioncd的信息进行访问和处理?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">

 

  Annotation?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">interface的异?/span>Q?/p>

 

    1Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">Annotationcd使用关键?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">@interface而不?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">interface?/p>

 

  q个关键字声明隐含了一个信息:(x)它是l承?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">java.lang.annotation.Annotation接口Qƈ非声明了一?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">interface

 

    2Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">Annotationcd、方法定义是独特的、受限制的?/p>

 

  Annotation cd的方法必d明ؓ(f)无参数、无异常抛出的。这些方法定义了annotation的成员:(x)Ҏ(gu)名成Z成员名,而方法返回值成Z成员的类型。而方法返回值类型必Mؓ(f)primitivecd?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">Classcd、枚丄型?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">annotationcd或者由前面cd之一作ؓ(f)元素的一l数l。方法的后面可以使用 default和一个默认数值来声明成员的默认|null不能作ؓ(f)成员默认|q与我们在非annotationcd中定义方法有很大不同?/p>

 

  Annotationcd和它的方法不能?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">annotationcd的参数、成员不能是generic。只有返回值类型是Class的方法可以在annotationcd中?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">genericQ因为此Ҏ(gu)能够用类转换各U类型{换ؓ(f)Class?/p>

 

    3Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">Annotationcd又与接口有着q似之处?/p>

 

  它们可以定义帔R、静态成员类型(比如枚Dcd定义Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">Annotationcd也可以如接口一般被实现或者ѝ?/p>

 

 

?/span>、应用场?/span>

 

  annotation一般作ZU辅助途径Q应用在软g框架或工具中Q在q些工具cMҎ(gu)不同?annontation注解信息采取不同的处理过E或改变相应E序元素Q类、方法及(qing)成员变量{)的行为?/p>

 

  例如Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">Junit?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">Struts?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">Spring{流行工h架中均广泛用了annontion。代码的灵zL大提高?/p>

 

 

 ?/span>、常见标准的Annotation

 

  ?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">java5版本开始,自带了三U标?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">annontationcd,

 

    Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">1Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">Override

 

  java.lang.Override 是一?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">marker annotationcdQ它被用作标注方法。它说明了被标注的方法重载了父类的方法,起到了断a的作用。如果我们用了q种annotation在一个没有覆盖父cL法的Ҏ(gu)Ӟjava~译器将以一个编译错误来警示?/p>

 

  q个annotaton常常在我们试图覆盖父cL法而确又写错了Ҏ(gu)名时加一个保障性的校验q程?/p>

 

    Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">2Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">Deprecated

 

  Deprecated也是一U?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">marker annotation。当一个类型或者类型成员?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">@Deprecated修饰的话Q编译器不鼓励使用q个被标注的E序元素。所以用这U修饰具有一定的 “延箋?#8221;Q如果我们在代码中通过l承或者覆盖的方式使用了这个过时的cd或者成员,虽然l承或者覆盖后的类型或者成员ƈ不是被声明ؓ(f) @DeprecatedQ但~译器仍然要报警?/p>

 

  注意Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">@Deprecatedq个annotationcd?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">javadoc中的 @deprecatedq个tag是有区别的:(x)前者是java~译器识别的Q而后者是?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">javadoc工具所识别用来生成文档Q包含程序成员ؓ(f)什么已l过时、它应当如何被禁止或者替代的描述Q?/p>

 

    Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">3Q?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">SuppressWarnings

 

  此注解能告诉Java~译器关闭对cR方法及(qing)成员变量的警告?/p>

 

  有时~译时会(x)提出一些警告,对于q些警告有的隐藏着BugQ有的是无法避免的,对于某些不想看到的警告信息,可以通过q个注解来屏蔽?/p>

 

  SuppressWarning不是一?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">marker annotation。它有一个类型ؓ(f)String[]的成员,q个成员的gؓ(f)被禁止的警告名。对?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">javac~译器来Ԍ?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">-Xlint选项有效的警告名也同样对@SuppressWarings有效Q同时编译器忽略掉无法识别的警告名?/p>

 

  annotation语法允许?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">annotation名后跟括P括号中是使用逗号分割?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">name=value对用于ؓ(f)annotation的成员赋|(x)

 

代码Q?/p>

 

@SuppressWarnings(value={"unchecked","fallthrough"})

public void lintTrap() { /* sloppy method body omitted */ }

 

 

 

在这个例子中SuppressWarnings annotationcd只定义了一个单一的成员,所以只有一个简单的value={...}作ؓ(f)name=value寏V又׃成员值是一个数l,故用大括号来声明数l倹{?/p>

 

 

注意Q我们可以在下面的情况中~写annotationQ当annotation只有单一成员Qƈ成员命名?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">"value="。这时可以省?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">"value="。比如将上面?span style="font-family: DejaVu Serif, serif" face="DejaVu Serif, serif">SuppressWarnings annotationq行~写Q?/p>

 

代码Q?/p>

 

@SuppressWarnings({"unchecked","fallthrough"})

 

 

 

 

如果SuppressWarnings所声明的被止警告个数Z个时Q可以省d括号Q?/p>

 

 

 

@SuppressWarnings("unchecked")

 

 

 

?/span>、自定义annontationCZ

 

  CZ共涉?qing)四个类Q?/p>

  清单1:Author.java

复制代码
package com.magc.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* 定义作者信息,name和group
*
@author magc
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface Author {

String name();
String group();
}
复制代码

  清单2:Description.java

复制代码
/**
*
*/
package com.magc.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
*
@author magc
*
* 定义描述信息 value
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented

public @interface Description {
String value();
}
复制代码

清单3:Utility.java

复制代码
package com.magc.annotation;

@Description(value
= "q是一个有用的工具c?/span>")
public class Utility {

@Author(name
= "haoran_202",group="com.magc")
public String work()
{
return "work over!";
}



}
复制代码

注:(x)q是个普通的Javac,q行了@Description和@Author注解?/p>

清单3:AnalysisAnnotation.java

复制代码
package com.magc.annotation;

import java.lang.reflect.Method;

public class AnalysisAnnotation {
/**
* 在运行时分析处理annotationcd的信?br /> *
*
*/
public static void main(String[] args) {
try {
//通过q行时反API获得annotation信息
Class rt_class = Class.forName("com.magc.annotation.Utility");
Method[] methods
= rt_class.getMethods();

boolean flag = rt_class.isAnnotationPresent(Description.class);

if(flag)
{
Description description
= (Description)rt_class.getAnnotation(Description.class);
System.out.println(
"Utility's Description--->"+description.value());
for (Method method : methods) {
if(method.isAnnotationPresent(Author.class))
{
Author author
= (Author)method.getAnnotation(Author.class);
System.out.println(
"Utility's Author--->"+author.name()+" from "+author.group());

}
}
}


}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}

}
复制代码

注:(x)q是个与自定义@Description和@Author配套的基框架或工L(fng)Q通过此类来获得与普通JavacUtility.java兌的信?xq和作者?/p>

q行AnalysisAnnotation,输出l果为:(x)

Utility's Description--->q是一个有用的工具c?/span>
Utility's Author--->haoran_202 from com.magc



ForMeBlog 2015-06-11 18:06 发表评论
]]>ORACLEU联查询http://www.aygfsteel.com/feng0801/archive/2015/03/12/423398.htmlForMeBlogForMeBlogThu, 12 Mar 2015 04:04:00 GMThttp://www.aygfsteel.com/feng0801/archive/2015/03/12/423398.htmlhttp://www.aygfsteel.com/feng0801/comments/423398.htmlhttp://www.aygfsteel.com/feng0801/archive/2015/03/12/423398.html#Feedback0http://www.aygfsteel.com/feng0801/comments/commentRss/423398.htmlhttp://www.aygfsteel.com/feng0801/services/trackbacks/423398.html
在ORACLE 数据库中有一U方法可以实现联查?br />select *                //要查询的字段
from table              //h子接点ID与父接点ID的表 
start with selfid=id      //l定一个startid(字段名ؓ(f)子接点IDQ及(qing)开始的ID?
connect by prior selfid=parentid       //联接条g为子接点{于父接点,不能?br />
q个SQL主要用于菜单的联查询,l一个父接点可以查出所有的子接炏V及(qing)子接点的子接点,一查到底,很实用。不q呢q个E序只能在oracle里面用,我目前还不知道在其它数据库里是怎么调用的。等我找CQ再贴出来与大家分n?/font>
q个E序Q估计好多h看不明白Q其实放了这么久我也一时没看明白,重新了一下,补充说明一下,不然我下ơ又看不懂了?/font>
以一个windowspȝ的菜单ؓ(f)例。我那一个这L(fng)表menu?/font>
说明Q?/font>
mid:菜单的ID?/font>
mnameQ菜单名U?/font>
mpidQ菜单的
quickeyQ快捷键
validate:权限表(存放userid,或者角色idQ?/font>
mid mname mpid quickey validate                                                                  
1 文g   ctrl+f 1Q?Q?Q?Q?1Q?3Q?5
2 ~辑   ctrl+e  
3 新徏 1 alt+w  
4 文g?/td> 3  

 

如果我想知道?#8220;文g”菜单下有那些子菜单的话。我可以这L(fng)q个SQLE序Q?/div>
select * from menu
start with mid=1     
connect by prior mid=mpid;
q样可以把 “文g”里的子菜单全部列出来了。当然实际应用不?x)这么简单,如附加其实条Ӟ其是权限管理,q时Ҏ(gu)你的pȝ要求Q是对个个验证,q是对角色验证,把这些h的ID攑֜validateq个字段里,l成一个字W串QN个ID用逗号隔开Q(注意Q在往数据库保存时要注意对字符串处理一下,截取掉最后一个逗号q样可以节省很多ȝQ?/div>
select * from menu
where validate in(……)
and mid in(
   select mid from menu  //q里不能?号了?/div>
   start with mid=1     
   connect by prior mid=mpid;
)
最后再补充一点关于随机查询的代码
select * from user order by sys_guid()


ForMeBlog 2015-03-12 12:04 发表评论
]]>如何以Java实现|页截图技?/title><link>http://www.aygfsteel.com/feng0801/archive/2015/01/21/422317.html</link><dc:creator>ForMeBlog</dc:creator><author>ForMeBlog</author><pubDate>Wed, 21 Jan 2015 04:00:00 GMT</pubDate><guid>http://www.aygfsteel.com/feng0801/archive/2015/01/21/422317.html</guid><wfw:comment>http://www.aygfsteel.com/feng0801/comments/422317.html</wfw:comment><comments>http://www.aygfsteel.com/feng0801/archive/2015/01/21/422317.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/feng0801/comments/commentRss/422317.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/feng0801/services/trackbacks/422317.html</trackback:ping><description><![CDATA[<p>今天看到某网友关?#8220;如何以Java实现|页截图技?#8221;的咨询帖Q由于出现该咨询的地炚w怸适合较长回复Q故以博文Ş式回{?/p> <p> </p> <p>事实上,如果(zhn)想以Java实现|页截图Q也是“输入一D늽址Q几U钟q后p截取一张网늾略图”的效果。那么,(zhn)至有3U方式可以选择?/p> <p> </p> <p><span style="color: #ff6600">1、最直接的方?#8212;—使用Robot</span> </p> <p> </p> <p><strong>Ҏ(gu)详解Q该Ҏ(gu)利用Robat提供的强大桌面操作能力,性调用浏览器打开指定|页Qƈ网信息保存到本地?/strong> </p> <p> </p> <p>优势Q简单易用,不需要Q何第三方插g?/p> <p> </p> <p>~点Q不能同时处理大量数据,技术含量过低,属于应急型技巧?/p> <p> </p> <p>实现Ҏ(gu)Q用如下代码即?/p><br /> <p> </p> <p> </p> <div id="wmqeeuq" class="dp-highlighter bg_java"> <div id="wmqeeuq" class="bar"> <div id="wmqeeuq" class="tools"><strong>[java]</strong> <a class="ViewSource" title="view plain" href="#">view plain</a><a class="CopyToClipboard" title="copy" href="http://www.aygfsteel.com/feng0801/admin/EditPosts.aspx?opt=1#">copy</a><a class="PrintSource" title="print" href="#">print</a><a class="About" title="?" href="http://www.aygfsteel.com/feng0801/admin/EditPosts.aspx?opt=1#">?</a></div></div> <ol class="dp-j"><li id="wmqeeuq" class="alt"><span id="wmqeeuq" class="keyword">public</span><span> </span><span id="wmqeeuq" class="keyword">static</span><span> </span><span id="wmqeeuq" class="keyword">void</span><span> main(String[] args) </span><span id="wmqeeuq" class="keyword">throws</span><span> MalformedURLException,  </span></li><li><span>        IOException, URISyntaxException, AWTException {  </span></li><li id="wmqeeuq" class="alt"><span>    </span><span id="wmqeeuq" class="comment">//此方法仅适用于JdK1.6?qing)以上版?</span><span>  </span></span></li><li><span>    Desktop.getDesktop().browse(  </span></li><li id="wmqeeuq" class="alt"><span>            </span><span id="wmqeeuq" class="keyword">new</span><span> URL(</span><span id="wmqeeuq" class="string">"http://google.com/intl/en/"</span><span>).toURI());  </span></span></li><li><span>    Robot robot = </span><span id="wmqeeuq" class="keyword">new</span><span> Robot();  </span></span></li><li id="wmqeeuq" class="alt"><span>    robot.delay(</span><span id="wmqeeuq" class="number">10000</span><span>);  </span></span></li><li><span>    Dimension d = </span><span id="wmqeeuq" class="keyword">new</span><span> Dimension(Toolkit.getDefaultToolkit().getScreenSize());  </span></span></li><li id="wmqeeuq" class="alt"><span>    </span><span id="wmqeeuq" class="keyword">int</span><span> width = (</span><span id="wmqeeuq" class="keyword">int</span><span>) d.getWidth();  </span></span></li><li><span>    </span><span id="wmqeeuq" class="keyword">int</span><span> height = (</span><span id="wmqeeuq" class="keyword">int</span><span>) d.getHeight();  </span></span></li><li id="wmqeeuq" class="alt"><span>    </span><span id="wmqeeuq" class="comment">//最大化览?</span><span>  </span></span></li><li><span>    robot.keyRelease(KeyEvent.VK_F11);  </span></li><li id="wmqeeuq" class="alt"><span>    robot.delay(</span><span id="wmqeeuq" class="number">2000</span><span>);  </span></span></li><li><span>    Image image = robot.createScreenCapture(</span><span id="wmqeeuq" class="keyword">new</span><span> Rectangle(</span><span id="wmqeeuq" class="number">0</span><span>, </span><span id="wmqeeuq" class="number">0</span><span>, width,  </span></span></li><li id="wmqeeuq" class="alt"><span>            height));  </span></li><li><span>    BufferedImage bi = </span><span id="wmqeeuq" class="keyword">new</span><span> BufferedImage(width, height,  </span></span></li><li id="wmqeeuq" class="alt"><span>            BufferedImage.TYPE_INT_RGB);  </span></li><li><span>    Graphics g = bi.createGraphics();  </span></li><li id="wmqeeuq" class="alt"><span>    g.drawImage(image, </span><span id="wmqeeuq" class="number">0</span><span>, </span><span id="wmqeeuq" class="number">0</span><span>, width, height, </span><span id="wmqeeuq" class="keyword">null</span><span>);  </span></span></li><li><span>    </span><span id="wmqeeuq" class="comment">//保存囄 </span><span>  </span></span></li><li id="wmqeeuq" class="alt"><span>    ImageIO.write(bi, </span><span id="wmqeeuq" class="string">"jpg"</span><span>, </span><span id="wmqeeuq" class="keyword">new</span><span> File(</span><span id="wmqeeuq" class="string">"google.jpg"</span><span>));  </span></span></li><li><span>}  </span></li></ol></div><textarea style="display: none" class="java" rows="15" cols="50" name="code"> public static void main(String[] args) throws MalformedURLException, IOException, URISyntaxException, AWTException { //此方法仅适用于JdK1.6?qing)以上版? Desktop.getDesktop().browse( new URL("http://google.com/intl/en/").toURI()); Robot robot = new Robot(); robot.delay(10000); Dimension d = new Dimension(Toolkit.getDefaultToolkit().getScreenSize()); int width = (int) d.getWidth(); int height = (int) d.getHeight(); //最大化览? robot.keyRelease(KeyEvent.VK_F11); robot.delay(2000); Image image = robot.createScreenCapture(new Rectangle(0, 0, width, height)); BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics g = bi.createGraphics(); g.drawImage(image, 0, 0, width, height, null); //保存囄 ImageIO.write(bi, "jpg", new File("google.jpg")); } </textarea> <p> </p> <p> </p> <p><span style="color: #ff6600">2、最常规的方?#8212;—利用JNIQ调用第三方C/C++lg</span> <br /></p> <p><strong>Ҏ(gu)详解Q目前来ԌJava领域对于|页截图lg的开发明显不I商机Q)Q当(zhn)需要完成此U操作时Q算得上到了Java的Y肋。但是,众所周知Java也拥有强大的JNI能力Q可以轻易将C/C++开发的同类lg引ؓ(f)q?/strong> </p> <p>优势Q实现简单,只需要封装对应的DLL文gQ就可以让Java实现同类功能?/p> <p> </p> <p>劣势Q同其他JNI实现一P在跨q_时存在隐(zhn),而且(zhn)的E序不再属于纯Java应用?/p> <p> </p> <p>实现Ҏ(gu)Q可参见此用例,具体装何种C/C++lg误行选择?/p> <p> </p> <p>PSQ示例来源于ACA HTML to Image Converter目Q?a >http://www.acasystems.com/en/web-thumb-activex/faq-convert-html-to-image-in-java.htm</a> Q,q是一个收费的HTML转ImageW三方组Ӟ但封装方式在Java中大同小异?/p> <p> </p> <p>引用JNI装Q?/p> <p> </p> <p> </p> <p> </p> <div id="wmqeeuq" class="dp-highlighter bg_java"> <div id="wmqeeuq" class="bar"> <div id="wmqeeuq" class="tools"><strong>[java]</strong> <a class="ViewSource" title="view plain" ><u><font color="#0000ff">view plain</font></u></a><a class="CopyToClipboard" title="copy" ><u><font color="#0000ff">copy</font></u></a><a class="PrintSource" title="print" ><u><font color="#0000ff">print</font></u></a><a class="About" title="?" ><u><font color="#0000ff">?</font></u></a></div></div> <ol class="dp-j"><li id="wmqeeuq" class="alt"><span id="wmqeeuq" class="keyword">import</span><span> sun.awt.*;  </span></li><li><span></span><span id="wmqeeuq" class="keyword">import</span><span> java.awt.*;  </span></span></li><li id="wmqeeuq" class="alt"><span></span><span id="wmqeeuq" class="keyword">import</span><span> javax.swing.*;  </span></span></li><li><span></span><span id="wmqeeuq" class="keyword">import</span><span> java.awt.event.*;  </span></span></li><li id="wmqeeuq" class="alt"><span></span><span id="wmqeeuq" class="keyword">import</span><span> java.awt.*;  </span></span></li><li><span></span><span id="wmqeeuq" class="keyword">import</span><span> java.awt.peer.*;  </span></span></li><li id="wmqeeuq" class="alt"><span></span><span id="wmqeeuq" class="keyword">public</span><span> </span><span id="wmqeeuq" class="keyword">class</span><span> Snap  </span></span></li><li><span>{  </span></li><li id="wmqeeuq" class="alt"><span>  </span><span id="wmqeeuq" class="keyword">static</span><span>  </span></span></li><li><span>  {  </span></li><li id="wmqeeuq" class="alt"><span>    System.loadLibrary(</span><span id="wmqeeuq" class="string">"Snap"</span><span>);  </span></span></li><li><span>  }  </span></li><li id="wmqeeuq" class="alt"><span>  </span><span id="wmqeeuq" class="keyword">public</span><span> </span><span id="wmqeeuq" class="keyword">static</span><span> </span><span id="wmqeeuq" class="keyword">void</span><span> main( String[] argv )  </span></span></li><li><span>  {  </span></li><li id="wmqeeuq" class="alt"><span>    Snap t_xSnap = </span><span id="wmqeeuq" class="keyword">new</span><span> Snap();  </span></span></li><li><span>    t_xSnap.Start(</span><span id="wmqeeuq" class="string">"http://www.google.com"</span><span>, </span><span id="wmqeeuq" class="string">"snapshot-google.png"</span><span>);  </span></span></li><li id="wmqeeuq" class="alt"><span>  }  </span></li><li><span>  </span><span id="wmqeeuq" class="keyword">public</span><span> </span><span id="wmqeeuq" class="keyword">native</span><span> </span><span id="wmqeeuq" class="keyword">void</span><span> Start(String pi_strURL, String pi_strImageName);  </span></span></li><li id="wmqeeuq" class="alt"><span>}  </span></li></ol></div> <p><textarea style="display: none" class="java" rows="15" cols="50" name="code">import sun.awt.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.awt.*; import java.awt.peer.*; public class Snap { static { System.loadLibrary("Snap"); } public static void main( String[] argv ) { Snap t_xSnap = new Snap(); t_xSnap.Start("http://www.google.com", "snapshot-google.png"); } public native void Start(String pi_strURL, String pi_strImageName); } </textarea> </p> <p> </p> <p> </p> <p>CPP部分的实玎ͼ(x)</p> <p> </p> <p> </p> <p> </p> <div id="wmqeeuq" class="dp-highlighter bg_java"> <div id="wmqeeuq" class="bar"> <div id="wmqeeuq" class="tools"><strong>[java]</strong> <a class="ViewSource" title="view plain" ><u><font color="#0000ff">view plain</font></u></a><a class="CopyToClipboard" title="copy" ><u><font color="#0000ff">copy</font></u></a><a class="PrintSource" title="print" ><u><font color="#0000ff">print</font></u></a><a class="About" title="?" ><u><font color="#0000ff">?</font></u></a></div></div> <ol class="dp-j"><li id="wmqeeuq" class="alt"><span>#include <windows.h>  </span></li><li><span>#include <atlbase.h>  </span></li><li id="wmqeeuq" class="alt"><span>#include </span><span id="wmqeeuq" class="string">"snap.h"</span><span>  </span></span></li><li><span>#pragma comment(lib,</span><span id="wmqeeuq" class="string">"atl.lib"</span><span>)  </span></span></li><li id="wmqeeuq" class="alt"><span>#</span><span id="wmqeeuq" class="keyword">import</span><span> </span><span id="wmqeeuq" class="string">"./../../acawebthumb.dll"</span><span> no_namespace  </span></span></li><li><span>JNIEXPORT </span><span id="wmqeeuq" class="keyword">void</span><span> JNICALL Java_Snap_Start(JNIEnv *pEnv, jobject, jstring pi_strUrl, jstring pi_strFileName)  </span></span></li><li id="wmqeeuq" class="alt"><span>{  </span></li><li><span>  CoInitialize(</span><span id="wmqeeuq" class="number">0</span><span>);  </span></span></li><li id="wmqeeuq" class="alt"><span>  _bstr_t t_strUrl = pEnv->GetStringUTFChars(pi_strUrl, </span><span id="wmqeeuq" class="number">0</span><span>);  </span></span></li><li><span>  _bstr_t t_strFileName = pEnv->GetStringUTFChars(pi_strFileName, </span><span id="wmqeeuq" class="number">0</span><span>);      </span></span></li><li id="wmqeeuq" class="alt"><span>  IThumbMakerPtr HTML_Converter = NULL;  </span></li><li><span>  HRESULT hr = HTML_Converter.CreateInstance(L</span><span id="wmqeeuq" class="string">"ACAWebThumb.ThumbMaker"</span><span>);      </span></span></li><li id="wmqeeuq" class="alt"><span>  </span><span id="wmqeeuq" class="keyword">if</span><span> (SUCCEEDED(hr))  </span></span></li><li><span>  {   </span></li><li id="wmqeeuq" class="alt"><span>    HTML_Converter->SetURL(t_strUrl);  </span></li><li><span>    </span><span id="wmqeeuq" class="keyword">if</span><span> ( </span><span id="wmqeeuq" class="number">0</span><span> == HTML_Converter->StartSnap() )  </span></span></li><li id="wmqeeuq" class="alt"><span>      HTML_Converter->SaveImage(t_strFileName);  </span></li><li><span>  }  </span></li><li id="wmqeeuq" class="alt"><span>  </span><span id="wmqeeuq" class="keyword">if</span><span> (HTML_Converter)  </span></span></li><li><span>    HTML_Converter.Release();  </span></li><li id="wmqeeuq" class="alt"><span>  CoUninitialize();           </span></li><li><span>}  </span></li></ol></div> <p><textarea style="display: none" class="java" rows="15" cols="50" name="code">#include <windows.h> #include <atlbase.h> #include "snap.h" #pragma comment(lib,"atl.lib") #import "./../../acawebthumb.dll" no_namespace JNIEXPORT void JNICALL Java_Snap_Start(JNIEnv *pEnv, jobject, jstring pi_strUrl, jstring pi_strFileName) { CoInitialize(0); _bstr_t t_strUrl = pEnv->GetStringUTFChars(pi_strUrl, 0); _bstr_t t_strFileName = pEnv->GetStringUTFChars(pi_strFileName, 0); IThumbMakerPtr HTML_Converter = NULL; HRESULT hr = HTML_Converter.CreateInstance(L"ACAWebThumb.ThumbMaker"); if (SUCCEEDED(hr)) { HTML_Converter->SetURL(t_strUrl); if ( 0 == HTML_Converter->StartSnap() ) HTML_Converter->SaveImage(t_strFileName); } if (HTML_Converter) HTML_Converter.Release(); CoUninitialize(); } </textarea> </p> <p> </p> <p> </p> <p>以该lg囑փ化yahoo界面的效果图Q?/p> <p> </p> <p><img alt="00" src="http://image.acasystems.com/html-to-image-converter/ex-www.yahoo.com-200.jpg" width="200" height="216" /> </p> <p><span style="color: #ff6600"><br /></span></p> <p><span style="color: #ff6600">3、最扎实的方?#8212;—自行解析HTML标记Qƈ其囑փ?/span> </p> <p> </p> <p><strong>Ҏ(gu)详解Q众所周知QHTML之所以在览器中以具体的|页格式出现Qƈ非服务器端传了一整个应用到客L(fng)Q而是源自于浏览器对于客户端自行解析的l果。因此,只要我们对应的解析一一实现Q那么将|页囑Ş化,将不是什么难事?/strong> </p> <p><strong><br /></strong></p> <p>优势Q纯Java实现Q一x逸,一旦开发完成则永远通用Q而且有一定的商用价倹{?/p> <p> </p> <p>劣势Q开发费Ӟ且需要针对不同语法做_分析Q才能保证输出的基本正确。尤其在涉及(qing)到JavaScript解析Ӟ隑ֺ尤其增大?/p> <p> </p> <p>实现Ҏ(gu)Q目前尚无具体案例可供参考。但是,׃Java有jdic之类的浏览器目存在Q?a >https://jdic.dev.java.net/</a> Q,而Java囑Ş界面又属l制生成。从理论上说Q我们可以将所有具备Graphics的组件图形化保存?/p> <p> </p> <p>而如果自行解析,那么(zhn)需要徏立HTML解析器(或用第三方的,万幸Java在这斚w的组件很多)Q了解Java2D机制Q了解何时该使用drawStringl制文字Q何时又该用drawImage插入囄{等?/p> <p> </p> <p><span style="color: #000000"><br /></span></p> <p><strong><span style="color: #000000">补充Q?/span> </strong></p> <p> </p> <p>q是一个利用内|浏览器截图的示例,使用了DJNativeSwinglg?/p> <p> </p> <p>CZ工程下蝲地址QEclipse工程Q含libQ:(x)<a >http://greenvm.googlecode.com/files/Screenshot.7z</a></p> <p> </p> <p> </p> <p> </p> <p> </p> <div id="wmqeeuq" class="dp-highlighter bg_java"> <div id="wmqeeuq" class="bar"> <div id="wmqeeuq" class="tools"><strong>[java]</strong> <a class="ViewSource" title="view plain" ><u><font color="#0000ff">view plain</font></u></a><a class="CopyToClipboard" title="copy" ><u><font color="#0000ff">copy</font></u></a><a class="PrintSource" title="print" ><u><font color="#0000ff">print</font></u></a><a class="About" title="?" ><u><font color="#0000ff">?</font></u></a></div></div> <ol class="dp-j"><li id="wmqeeuq" class="alt"><span id="wmqeeuq" class="keyword">import</span><span> java.awt.BorderLayout;  </span></li><li><span></span><span id="wmqeeuq" class="keyword">import</span><span> java.awt.Dimension;  </span></span></li><li id="wmqeeuq" class="alt"><span></span><span id="wmqeeuq" class="keyword">import</span><span> java.awt.FlowLayout;  </span></span></li><li><span></span><span id="wmqeeuq" class="keyword">import</span><span> java.awt.image.BufferedImage;  </span></span></li><li id="wmqeeuq" class="alt"><span></span><span id="wmqeeuq" class="keyword">import</span><span> java.io.File;  </span></span></li><li><span></span><span id="wmqeeuq" class="keyword">import</span><span> java.io.IOException;  </span></span></li><li id="wmqeeuq" class="alt"><span></span><span id="wmqeeuq" class="keyword">import</span><span> javax.imageio.ImageIO;  </span></span></li><li><span></span><span id="wmqeeuq" class="keyword">import</span><span> javax.swing.JFrame;  </span></span></li><li id="wmqeeuq" class="alt"><span></span><span id="wmqeeuq" class="keyword">import</span><span> javax.swing.JPanel;  </span></span></li><li><span></span><span id="wmqeeuq" class="keyword">import</span><span> javax.swing.SwingUtilities;  </span></span></li><li id="wmqeeuq" class="alt"><span></span><span id="wmqeeuq" class="keyword">import</span><span> chrriis.dj.nativeswing.swtimpl.NativeComponent;  </span></span></li><li><span></span><span id="wmqeeuq" class="keyword">import</span><span> chrriis.dj.nativeswing.swtimpl.NativeInterface;  </span></span></li><li id="wmqeeuq" class="alt"><span></span><span id="wmqeeuq" class="keyword">import</span><span> chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;  </span></span></li><li><span></span><span id="wmqeeuq" class="keyword">import</span><span> chrriis.dj.nativeswing.swtimpl.components.WebBrowserAdapter;  </span></span></li><li id="wmqeeuq" class="alt"><span></span><span id="wmqeeuq" class="keyword">import</span><span> chrriis.dj.nativeswing.swtimpl.components.WebBrowserEvent;  </span></span></li><li><span></span><span id="wmqeeuq" class="keyword">public</span><span> </span><span id="wmqeeuq" class="keyword">class</span><span> Main </span><span id="wmqeeuq" class="keyword">extends</span><span> JPanel {  </span></span></li><li id="wmqeeuq" class="alt"><span>    </span><span id="wmqeeuq" class="comment">/**</span> </span></li><li><span id="wmqeeuq" class="comment">     * </span> </li><li id="wmqeeuq" class="alt"><span id="wmqeeuq" class="comment">     */</span><span>  </span></li><li><span>    </span><span id="wmqeeuq" class="keyword">private</span><span> </span><span id="wmqeeuq" class="keyword">static</span><span> </span><span id="wmqeeuq" class="keyword">final</span><span> </span><span id="wmqeeuq" class="keyword">long</span><span> serialVersionUID = 1L;  </span></span></li><li id="wmqeeuq" class="alt"><span>    </span><span id="wmqeeuq" class="comment">// 行分隔符 </span><span>  </span></span></li><li><span>    </span><span id="wmqeeuq" class="keyword">final</span><span> </span><span id="wmqeeuq" class="keyword">static</span><span> </span><span id="wmqeeuq" class="keyword">public</span><span> String LS = System.getProperty(</span><span id="wmqeeuq" class="string">"line.separator"</span><span>, </span><span id="wmqeeuq" class="string">"/n"</span><span>);  </span></span></li><li id="wmqeeuq" class="alt"><span>    </span><span id="wmqeeuq" class="comment">// 文g分割W?</span><span>  </span></span></li><li><span>    </span><span id="wmqeeuq" class="keyword">final</span><span> </span><span id="wmqeeuq" class="keyword">static</span><span> </span><span id="wmqeeuq" class="keyword">public</span><span> String FS = System.getProperty(</span><span id="wmqeeuq" class="string">"file.separator"</span><span>, </span><span id="wmqeeuq" class="string">"http://"</span><span>);  </span></span></li><li id="wmqeeuq" class="alt"><span>    </span><span id="wmqeeuq" class="comment">//以javascript脚本获得|页全屏后大?</span><span>  </span></span></li><li><span>    </span><span id="wmqeeuq" class="keyword">final</span><span> </span><span id="wmqeeuq" class="keyword">static</span><span> StringBuffer jsDimension;  </span></span></li><li id="wmqeeuq" class="alt"><span>      </span></li><li><span>    </span><span id="wmqeeuq" class="keyword">static</span><span> {  </span></span></li><li id="wmqeeuq" class="alt"><span>        jsDimension = </span><span id="wmqeeuq" class="keyword">new</span><span> StringBuffer();  </span></span></li><li><span>        jsDimension.append(</span><span id="wmqeeuq" class="string">"var width = 0;"</span><span>).append(LS);  </span></span></li><li id="wmqeeuq" class="alt"><span>        jsDimension.append(</span><span id="wmqeeuq" class="string">"var height = 0;"</span><span>).append(LS);  </span></span></li><li><span>        jsDimension.append(</span><span id="wmqeeuq" class="string">"if(document.documentElement) {"</span><span>).append(LS);  </span></span></li><li id="wmqeeuq" class="alt"><span>        jsDimension.append(  </span></li><li><span>                        </span><span id="wmqeeuq" class="string">"  width = Math.max(width, document.documentElement.scrollWidth);"</span><span>)  </span></span></li><li id="wmqeeuq" class="alt"><span>                .append(LS);  </span></li><li><span>        jsDimension.append(  </span></li><li id="wmqeeuq" class="alt"><span>                        </span><span id="wmqeeuq" class="string">"  height = Math.max(height, document.documentElement.scrollHeight);"</span><span>)  </span></span></li><li><span>                .append(LS);  </span></li><li id="wmqeeuq" class="alt"><span>        jsDimension.append(</span><span id="wmqeeuq" class="string">"}"</span><span>).append(LS);  </span></span></li><li><span>        jsDimension.append(</span><span id="wmqeeuq" class="string">"if(self.innerWidth) {"</span><span>).append(LS);  </span></span></li><li id="wmqeeuq" class="alt"><span>        jsDimension.append(</span><span id="wmqeeuq" class="string">"  width = Math.max(width, self.innerWidth);"</span><span>)  </span></span></li><li><span>                .append(LS);  </span></li><li id="wmqeeuq" class="alt"><span>        jsDimension.append(</span><span id="wmqeeuq" class="string">"  height = Math.max(height, self.innerHeight);"</span><span>)  </span></span></li><li><span>                .append(LS);  </span></li><li id="wmqeeuq" class="alt"><span>        jsDimension.append(</span><span id="wmqeeuq" class="string">"}"</span><span>).append(LS);  </span></span></li><li><span>        jsDimension.append(</span><span id="wmqeeuq" class="string">"if(document.body.scrollWidth) {"</span><span>).append(LS);  </span></span></li><li id="wmqeeuq" class="alt"><span>        jsDimension.append(  </span></li><li><span>                </span><span id="wmqeeuq" class="string">"  width = Math.max(width, document.body.scrollWidth);"</span><span>)  </span></span></li><li id="wmqeeuq" class="alt"><span>                .append(LS);  </span></li><li><span>        jsDimension.append(  </span></li><li id="wmqeeuq" class="alt"><span>                </span><span id="wmqeeuq" class="string">"  height = Math.max(height, document.body.scrollHeight);"</span><span>)  </span></span></li><li><span>                .append(LS);  </span></li><li id="wmqeeuq" class="alt"><span>        jsDimension.append(</span><span id="wmqeeuq" class="string">"}"</span><span>).append(LS);  </span></span></li><li><span>        jsDimension.append(</span><span id="wmqeeuq" class="string">"return width + ':' + height;"</span><span>);  </span></span></li><li id="wmqeeuq" class="alt"><span>    }  </span></li><li><span>  </span><span id="wmqeeuq" class="comment">//DJNativeSwinglg请于http://djproject.sourceforge.net/main/index.html下蝲 </span><span>  </span></span></li><li id="wmqeeuq" class="alt"><span>    </span><span id="wmqeeuq" class="keyword">public</span><span> Main(</span><span id="wmqeeuq" class="keyword">final</span><span> String url, </span><span id="wmqeeuq" class="keyword">final</span><span> </span><span id="wmqeeuq" class="keyword">int</span><span> maxWidth, </span><span id="wmqeeuq" class="keyword">final</span><span> </span><span id="wmqeeuq" class="keyword">int</span><span> maxHeight) {  </span></span></li><li><span>        </span><span id="wmqeeuq" class="keyword">super</span><span>(</span><span id="wmqeeuq" class="keyword">new</span><span> BorderLayout());  </span></span></li><li id="wmqeeuq" class="alt"><span>        JPanel webBrowserPanel = </span><span id="wmqeeuq" class="keyword">new</span><span> JPanel(</span><span id="wmqeeuq" class="keyword">new</span><span> BorderLayout());  </span></span></li><li><span>        </span><span id="wmqeeuq" class="keyword">final</span><span> String fileName = System.currentTimeMillis() + </span><span id="wmqeeuq" class="string">".jpg"</span><span>;  </span></span></li><li id="wmqeeuq" class="alt"><span>        </span><span id="wmqeeuq" class="keyword">final</span><span> JWebBrowser webBrowser = </span><span id="wmqeeuq" class="keyword">new</span><span> JWebBrowser(</span><span id="wmqeeuq" class="keyword">null</span><span>);  </span></span></li><li><span>        webBrowser.setBarsVisible(</span><span id="wmqeeuq" class="keyword">false</span><span>);  </span></span></li><li id="wmqeeuq" class="alt"><span>        webBrowser.navigate(url);  </span></li><li><span>        webBrowserPanel.add(webBrowser, BorderLayout.CENTER);  </span></li><li id="wmqeeuq" class="alt"><span>        add(webBrowserPanel, BorderLayout.CENTER);  </span></li><li><span>        JPanel panel = </span><span id="wmqeeuq" class="keyword">new</span><span> JPanel(</span><span id="wmqeeuq" class="keyword">new</span><span> FlowLayout(FlowLayout.CENTER, </span><span id="wmqeeuq" class="number">4</span><span>, </span><span id="wmqeeuq" class="number">4</span><span>));  </span></span></li><li id="wmqeeuq" class="alt"><span>        webBrowser.addWebBrowserListener(</span><span id="wmqeeuq" class="keyword">new</span><span> WebBrowserAdapter() {  </span></span></li><li><span>            </span><span id="wmqeeuq" class="comment">// 监听加蝲q度 </span><span>  </span></span></li><li id="wmqeeuq" class="alt"><span>            </span><span id="wmqeeuq" class="keyword">public</span><span> </span><span id="wmqeeuq" class="keyword">void</span><span> loadingProgressChanged(WebBrowserEvent e) {  </span></span></li><li><span>                </span><span id="wmqeeuq" class="comment">// 当加载完毕时 </span><span>  </span></span></li><li id="wmqeeuq" class="alt"><span>                </span><span id="wmqeeuq" class="keyword">if</span><span> (e.getWebBrowser().getLoadingProgress() == </span><span id="wmqeeuq" class="number">100</span><span>) {  </span></span></li><li><span>                    String result = (String) webBrowser  </span></li><li id="wmqeeuq" class="alt"><span>                            .executeJavascriptWithResult(jsDimension.toString());  </span></li><li><span>                    </span><span id="wmqeeuq" class="keyword">int</span><span> index = result == </span><span id="wmqeeuq" class="keyword">null</span><span> ? -</span><span id="wmqeeuq" class="number">1</span><span> : result.indexOf(</span><span id="wmqeeuq" class="string">":"</span><span>);  </span></span></li><li id="wmqeeuq" class="alt"><span>                    NativeComponent nativeComponent = webBrowser  </span></li><li><span>                            .getNativeComponent();  </span></li><li id="wmqeeuq" class="alt"><span>                    Dimension originalSize = nativeComponent.getSize();  </span></li><li><span>                    Dimension imageSize = </span><span id="wmqeeuq" class="keyword">new</span><span> Dimension(Integer.parseInt(result  </span></span></li><li id="wmqeeuq" class="alt"><span>                            .substring(</span><span id="wmqeeuq" class="number">0</span><span>, index)), Integer.parseInt(result  </span></span></li><li><span>                            .substring(index + </span><span id="wmqeeuq" class="number">1</span><span>)));  </span></span></li><li id="wmqeeuq" class="alt"><span>                    imageSize.width = Math.max(originalSize.width,  </span></li><li><span>                            imageSize.width + </span><span id="wmqeeuq" class="number">50</span><span>);  </span></span></li><li id="wmqeeuq" class="alt"><span>                    imageSize.height = Math.max(originalSize.height,  </span></li><li><span>                            imageSize.height + </span><span id="wmqeeuq" class="number">50</span><span>);  </span></span></li><li id="wmqeeuq" class="alt"><span>                    nativeComponent.setSize(imageSize);  </span></li><li><span>                    BufferedImage image = </span><span id="wmqeeuq" class="keyword">new</span><span> BufferedImage(imageSize.width,  </span></span></li><li id="wmqeeuq" class="alt"><span>                            imageSize.height, BufferedImage.TYPE_INT_RGB);  </span></li><li><span>                    nativeComponent.paintComponent(image);  </span></li><li id="wmqeeuq" class="alt"><span>                    nativeComponent.setSize(originalSize);  </span></li><li><span>                    </span><span id="wmqeeuq" class="comment">// 当网超出目标大时 </span><span>  </span></span></li><li id="wmqeeuq" class="alt"><span>                    </span><span id="wmqeeuq" class="keyword">if</span><span> (imageSize.width > maxWidth  </span></span></li><li><span>                            || imageSize.height > maxHeight) {  </span></li><li id="wmqeeuq" class="alt"><span>                        </span><span id="wmqeeuq" class="comment">//截图部分囑Ş </span><span>  </span></span></li><li><span>                        image = image.getSubimage(</span><span id="wmqeeuq" class="number">0</span><span>, </span><span id="wmqeeuq" class="number">0</span><span>, maxWidth, maxHeight);  </span></span></li><li id="wmqeeuq" class="alt"><span>                        </span><span id="wmqeeuq" class="comment">/*此部分ؓ(f)使用~略?/span> </span></li><li><span id="wmqeeuq" class="comment">                        int width = image.getWidth(), height = image</span> </li><li id="wmqeeuq" class="alt"><span id="wmqeeuq" class="comment">                            .getHeight();</span> </li><li><span id="wmqeeuq" class="comment">                         AffineTransform tx = new AffineTransform();</span> </li><li id="wmqeeuq" class="alt"><span id="wmqeeuq" class="comment">                        tx.scale((double) maxWidth / width, (double) maxHeight</span> </li><li><span id="wmqeeuq" class="comment">                                / height);</span> </li><li id="wmqeeuq" class="alt"><span id="wmqeeuq" class="comment">                        AffineTransformOp op = new AffineTransformOp(tx,</span> </li><li><span id="wmqeeuq" class="comment">                                AffineTransformOp.TYPE_NEAREST_NEIGHBOR);</span> </li><li id="wmqeeuq" class="alt"><span id="wmqeeuq" class="comment">                        //~小</span> </li><li><span id="wmqeeuq" class="comment">                        image = op.filter(image, null);*/</span><span>  </span></li><li id="wmqeeuq" class="alt"><span>                    }  </span></li><li><span>                    </span><span id="wmqeeuq" class="keyword">try</span><span> {  </span></span></li><li id="wmqeeuq" class="alt"><span>                        </span><span id="wmqeeuq" class="comment">// 输出囑փ </span><span>  </span></span></li><li><span>                        ImageIO.write(image, </span><span id="wmqeeuq" class="string">"jpg"</span><span>, </span><span id="wmqeeuq" class="keyword">new</span><span> File(fileName));  </span></span></li><li id="wmqeeuq" class="alt"><span>                    } </span><span id="wmqeeuq" class="keyword">catch</span><span> (IOException ex) {  </span></span></li><li><span>                        ex.printStackTrace();  </span></li><li id="wmqeeuq" class="alt"><span>                    }  </span></li><li><span>                    </span><span id="wmqeeuq" class="comment">// 退出操?</span><span>  </span></span></li><li id="wmqeeuq" class="alt"><span>                    System.exit(</span><span id="wmqeeuq" class="number">0</span><span>);  </span></span></li><li><span>                }  </span></li><li id="wmqeeuq" class="alt"><span>            }  </span></li><li><span>        }  </span></li><li id="wmqeeuq" class="alt"><span>        );  </span></li><li><span>        add(panel, BorderLayout.SOUTH);  </span></li><li id="wmqeeuq" class="alt"><span>    }  </span></li><li><span>    </span><span id="wmqeeuq" class="keyword">public</span><span> </span><span id="wmqeeuq" class="keyword">static</span><span> </span><span id="wmqeeuq" class="keyword">void</span><span> main(String[] args) {  </span></span></li><li id="wmqeeuq" class="alt"><span>        NativeInterface.open();  </span></li><li><span>        SwingUtilities.invokeLater(</span><span id="wmqeeuq" class="keyword">new</span><span> Runnable() {  </span></span></li><li id="wmqeeuq" class="alt"><span>            </span><span id="wmqeeuq" class="keyword">public</span><span> </span><span id="wmqeeuq" class="keyword">void</span><span> run() {  </span></span></li><li><span>                </span><span id="wmqeeuq" class="comment">// SWTlg转SwinglgQ不初始化父H体无法启动webBrowser </span><span>  </span></span></li><li id="wmqeeuq" class="alt"><span>                JFrame frame = </span><span id="wmqeeuq" class="keyword">new</span><span> JFrame(</span><span id="wmqeeuq" class="string">"以DJlg保存指定|页截图"</span><span>);  </span></span></li><li><span>                </span><span id="wmqeeuq" class="comment">// 加蝲指定面Q最大保存ؓ(f)640x480的截?</span><span>  </span></span></li><li id="wmqeeuq" class="alt"><span>                frame.getContentPane().add(  </span></li><li><span>                        </span><span id="wmqeeuq" class="keyword">new</span><span> Main(</span><span id="wmqeeuq" class="string">"http://blog.csdn.net/cping1982"</span><span>, </span><span id="wmqeeuq" class="number">640</span><span>, </span><span id="wmqeeuq" class="number">480</span><span>),  </span></span></li><li id="wmqeeuq" class="alt"><span>                        BorderLayout.CENTER);  </span></li><li><span>                frame.setSize(</span><span id="wmqeeuq" class="number">800</span><span>, </span><span id="wmqeeuq" class="number">600</span><span>);  </span></span></li><li id="wmqeeuq" class="alt"><span>                </span><span id="wmqeeuq" class="comment">// 仅初始化Q但不显C?</span><span>  </span></span></li><li><span>                frame.invalidate();  </span></li><li id="wmqeeuq" class="alt"><span>                frame.pack();  </span></li><li><span>                frame.setVisible(</span><span id="wmqeeuq" class="keyword">false</span><span>);  </span></span></li><li id="wmqeeuq" class="alt"><span>            }  </span></li><li><span>        });  </span></li><li id="wmqeeuq" class="alt"><span>        NativeInterface.runEventPump();  </span></li><li><span>    }  </span></li><li id="wmqeeuq" class="alt"><span>}  </span></li></ol></div> <p><textarea style="display: none" class="java" rows="15" cols="50" name="code">import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import chrriis.dj.nativeswing.swtimpl.NativeComponent; import chrriis.dj.nativeswing.swtimpl.NativeInterface; import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser; import chrriis.dj.nativeswing.swtimpl.components.WebBrowserAdapter; import chrriis.dj.nativeswing.swtimpl.components.WebBrowserEvent; public class Main extends JPanel { /** * */ private static final long serialVersionUID = 1L; // 行分隔符 final static public String LS = System.getProperty("line.separator", "/n"); // 文g分割W? final static public String FS = System.getProperty("file.separator", "http://"); //以javascript脚本获得|页全屏后大? final static StringBuffer jsDimension; static { jsDimension = new StringBuffer(); jsDimension.append("var width = 0;").append(LS); jsDimension.append("var height = 0;").append(LS); jsDimension.append("if(document.documentElement) {").append(LS); jsDimension.append( " width = Math.max(width, document.documentElement.scrollWidth);") .append(LS); jsDimension.append( " height = Math.max(height, document.documentElement.scrollHeight);") .append(LS); jsDimension.append("}").append(LS); jsDimension.append("if(self.innerWidth) {").append(LS); jsDimension.append(" width = Math.max(width, self.innerWidth);") .append(LS); jsDimension.append(" height = Math.max(height, self.innerHeight);") .append(LS); jsDimension.append("}").append(LS); jsDimension.append("if(document.body.scrollWidth) {").append(LS); jsDimension.append( " width = Math.max(width, document.body.scrollWidth);") .append(LS); jsDimension.append( " height = Math.max(height, document.body.scrollHeight);") .append(LS); jsDimension.append("}").append(LS); jsDimension.append("return width + ':' + height;"); } //DJNativeSwinglg请于http://djproject.sourceforge.net/main/index.html下蝲 public Main(final String url, final int maxWidth, final int maxHeight) { super(new BorderLayout()); JPanel webBrowserPanel = new JPanel(new BorderLayout()); final String fileName = System.currentTimeMillis() + ".jpg"; final JWebBrowser webBrowser = new JWebBrowser(null); webBrowser.setBarsVisible(false); webBrowser.navigate(url); webBrowserPanel.add(webBrowser, BorderLayout.CENTER); add(webBrowserPanel, BorderLayout.CENTER); JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 4)); webBrowser.addWebBrowserListener(new WebBrowserAdapter() { // 监听加蝲q度 public void loadingProgressChanged(WebBrowserEvent e) { // 当加载完毕时 if (e.getWebBrowser().getLoadingProgress() == 100) { String result = (String) webBrowser .executeJavascriptWithResult(jsDimension.toString()); int index = result == null ? -1 : result.indexOf(":"); NativeComponent nativeComponent = webBrowser .getNativeComponent(); Dimension originalSize = nativeComponent.getSize(); Dimension imageSize = new Dimension(Integer.parseInt(result .substring(0, index)), Integer.parseInt(result .substring(index + 1))); imageSize.width = Math.max(originalSize.width, imageSize.width + 50); imageSize.height = Math.max(originalSize.height, imageSize.height + 50); nativeComponent.setSize(imageSize); BufferedImage image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_INT_RGB); nativeComponent.paintComponent(image); nativeComponent.setSize(originalSize); // 当网超出目标大时 if (imageSize.width > maxWidth || imageSize.height > maxHeight) { //截图部分囑Ş image = image.getSubimage(0, 0, maxWidth, maxHeight); /*此部分ؓ(f)使用~略? int width = image.getWidth(), height = image .getHeight(); AffineTransform tx = new AffineTransform(); tx.scale((double) maxWidth / width, (double) maxHeight / height); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); //~小 image = op.filter(image, null);*/ } try { // 输出囑փ ImageIO.write(image, "jpg", new File(fileName)); } catch (IOException ex) { ex.printStackTrace(); } // 退出操? System.exit(0); } } } ); add(panel, BorderLayout.SOUTH); } public static void main(String[] args) { NativeInterface.open(); SwingUtilities.invokeLater(new Runnable() { public void run() { // SWTlg转SwinglgQ不初始化父H体无法启动webBrowser JFrame frame = new JFrame("以DJlg保存指定|页截图"); // 加蝲指定面Q最大保存ؓ(f)640x480的截? frame.getContentPane().add( new Main("http://blog.csdn.net/cping1982", 640, 480), BorderLayout.CENTER); frame.setSize(800, 600); // 仅初始化Q但不显C? frame.invalidate(); frame.pack(); frame.setVisible(false); } }); NativeInterface.runEventPump(); } } </textarea> </p> <p> </p> <p> </p> <p> </p><img src ="http://www.aygfsteel.com/feng0801/aggbug/422317.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/feng0801/" target="_blank">ForMeBlog</a> 2015-01-21 12:00 <a href="http://www.aygfsteel.com/feng0801/archive/2015/01/21/422317.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java文g下蝲 http://www.aygfsteel.com/feng0801/archive/2015/01/04/422028.htmlForMeBlogForMeBlogSun, 04 Jan 2015 08:32:00 GMThttp://www.aygfsteel.com/feng0801/archive/2015/01/04/422028.htmlhttp://www.aygfsteel.com/feng0801/comments/422028.htmlhttp://www.aygfsteel.com/feng0801/archive/2015/01/04/422028.html#Feedback0http://www.aygfsteel.com/feng0801/comments/commentRss/422028.htmlhttp://www.aygfsteel.com/feng0801/services/trackbacks/422028.htmlpublic HttpServletResponse download(String path, HttpServletResponse response) {
        
try {
            
// path是指Ʋ下载的文g的\径?/span>
            File file = new File(path);
            
// 取得文g名?/span>
            String filename = file.getName();
            
// 取得文g的后~名?/span>
            String ext = filename.substring(filename.lastIndexOf("."+ 1).toUpperCase();

            
// 以流的Ş式下载文件?/span>
            InputStream fis = new BufferedInputStream(new FileInputStream(path));
            
byte[] buffer = new byte[fis.available()];
            fis.read(buffer);
            fis.close();
            
// 清空response
            response.reset();
            
// 讄response的Header
            response.addHeader("Content-Disposition""attachment;filename=" + new String(filename.getBytes()));
            response.addHeader(
"Content-Length""" + file.length());
            OutputStream toClient 
= new BufferedOutputStream(response.getOutputStream());
            response.setContentType(
"application/octet-stream");
            toClient.write(buffer);
            toClient.flush();
            toClient.close();
        } 
catch (IOException ex) {
            ex.printStackTrace();
        }
        
return response;
    }

    
public void downloadLocal(HttpServletResponse response) throws FileNotFoundException {
        
// 下蝲本地文g
        String fileName = "Operator.doc".toString(); // 文g的默认保存名
        
// d中
        InputStream inStream = new FileInputStream("c:/Operator.doc");// 文g的存放\?br />        // 讄输出的格?/span>
        response.reset();
        response.setContentType(
"bin");
        response.addHeader(
"Content-Disposition""attachment; filename=\"" + fileName + "\"");
        
// 循环取出中的数?/span>
        byte[] b = new byte[100];
        
int len;
        
try {
            
while ((len = inStream.read(b)) > 0)
                response.getOutputStream().write(b, 
0, len);
            inStream.close();
        } 
catch (IOException e) {
            e.printStackTrace();
        }
    }

    
public void downloadNet(HttpServletResponse response) throws MalformedURLException {
        
// 下蝲|络文g
        int bytesum = 0;
        
int byteread = 0;

        URL url 
= new URL("windine.blogdriver.com/logo.gif");

        
try {
            URLConnection conn 
= url.openConnection();
            InputStream inStream 
= conn.getInputStream();
            FileOutputStream fs 
= new FileOutputStream("c:/abc.gif");

            
byte[] buffer = new byte[1204];
            
int length;
            
while ((byteread = inStream.read(buffer)) != -1) {
                bytesum 
+= byteread;
                System.out.println(bytesum);
                fs.write(buffer, 
0, byteread);
            }
        } 
catch (FileNotFoundException e) {
            e.printStackTrace();
        } 
catch (IOException e) {
            e.printStackTrace();
        }
    }
//支持在线打开文g的一U?
public void downLoad(String filePath, HttpServletResponse response, boolean isOnLine) throws Exception {
        File f 
= new File(filePath);
        
if (!f.exists()) {
            response.sendError(
404"File not found!");
            
return;
        }

        BufferedInputStream br 
= new BufferedInputStream(new FileInputStream(f));
        
byte[] buf = new byte[1024];
        
int len = 0;

        response.reset(); 
// 非常重要
        if (isOnLine) // 在线打开方式
            URL u = new URL("file:///" + filePath);
            response.setContentType(u.openConnection().getContentType());
            response.setHeader(
"Content-Disposition""inline; filename=" + f.getName());
            
// 文g名应该编码成UTF-8
        }
 else // U下载方?/span>
            response.setContentType("application/x-msdownload");
            response.setHeader(
"Content-Disposition""attachment; filename=" + f.getName());
        }

        OutputStream out 
= response.getOutputStream();
        
while ((len = br.read(buf)) > 0)
            out.write(buf, 
0, len);
        br.close();
        out.close();
    }
方式



ForMeBlog 2015-01-04 16:32 发表评论
]]>java修改xml文ghttp://www.aygfsteel.com/feng0801/archive/2014/07/29/401396.htmlForMeBlogForMeBlogTue, 29 Jul 2014 09:05:00 GMThttp://www.aygfsteel.com/feng0801/archive/2014/07/29/401396.htmlhttp://www.aygfsteel.com/feng0801/comments/401396.htmlhttp://www.aygfsteel.com/feng0801/archive/2014/07/29/401396.html#Feedback0http://www.aygfsteel.com/feng0801/comments/commentRss/401396.htmlhttp://www.aygfsteel.com/feng0801/services/trackbacks/401396.html原始的message.xml
<?xml version="1.0" encoding="UTF-8"?><users>
    
<Messages>
        
<sendName>sendUsers</sendName>
        
<receiveName>snake</receiveName>
        
<date>2007-12-04 12:20:00</date>
        
<status>1</status>
        
<message>this is Content</message>
    
</Messages>
</users>

javaE序
import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class UpdateXml {
    
public static boolean doc2XmlFile(Document document, String filename) {
        
boolean flag = true;
        
try {
           
            TransformerFactory tFactory 
= TransformerFactory.newInstance();
            Transformer transformer 
= tFactory.newTransformer();
           
            
// transformer.setOutputProperty(OutputKeys.ENCODING, "GB2312");
            DOMSource source = new DOMSource(document);
            StreamResult result 
= new StreamResult(new File(filename));
            transformer.transform(source, result);
        } 
catch (Exception ex) {
            flag 
= false;
            ex.printStackTrace();
        }
        
return flag;
    }

    
public static Document load(String filename) {
        Document document 
= null;
        
try {
            DocumentBuilderFactory factory 
= DocumentBuilderFactory
                    .newInstance();
            DocumentBuilder builder 
= factory.newDocumentBuilder();
            document 
= builder.parse(new File(filename));
            document.normalize();
        } 
catch (Exception ex) {
            ex.printStackTrace();
        }
        
return document;
    }

   
    
public static void xmlUpdateDemo() {
        Document document 
= load("message.xml");
        Node root 
= document.getDocumentElement();
       
        
if (root.hasChildNodes()) {
           
            NodeList ftpnodes 
= root.getChildNodes();
           
            
for (int i = 0; i < ftpnodes.getLength(); i++) {
                NodeList ftplist 
= ftpnodes.item(i).getChildNodes();
                
for (int k = 0; k < ftplist.getLength(); k++) {
                    Node subnode 
= ftplist.item(k);
                   
                    
// if (subnode.getNodeType()==Node.ELEMENT_NODE&&subnode.
                    
// getNodeName()=="ftp-chn")
                    
// {
                    
// ftpnodes.item(i).removeChild(subnode);
                    
// }
                   
                    
if (subnode.getNodeType() == Node.ELEMENT_NODE
                            
&& subnode.getNodeName() == "status") {
                        subnode.getFirstChild().setNodeValue(
"9");
                    }
                }

            }
        }

        doc2XmlFile(document, 
"message.xml");
    }

    
public static void main(String args[]) throws Exception {
        UpdateXml.xmlUpdateDemo();
    }
}

修改后的message.xml
<?xml version="1.0" encoding="UTF-8"?><users>
    
<Messages>
        
<sendName>sendUsers</sendName>
        
<receiveName>snake</receiveName>
        
<date>2007-12-04 12:20:00</date>
        
<status>9</status>
        
<message>this is Content</message>
    
</Messages>
</users>


ForMeBlog 2014-07-29 17:05 发表评论
]]>
ant 入门http://www.aygfsteel.com/feng0801/archive/2014/07/29/401513.htmlForMeBlogForMeBlogTue, 29 Jul 2014 09:01:00 GMThttp://www.aygfsteel.com/feng0801/archive/2014/07/29/401513.htmlhttp://www.aygfsteel.com/feng0801/comments/401513.htmlhttp://www.aygfsteel.com/feng0801/archive/2014/07/29/401513.html#Feedback0http://www.aygfsteel.com/feng0801/comments/commentRss/401513.htmlhttp://www.aygfsteel.com/feng0801/services/trackbacks/401513.html阅读全文

ForMeBlog 2014-07-29 17:01 发表评论
]]>
Ant使用例子http://www.aygfsteel.com/feng0801/archive/2014/07/29/416297.htmlForMeBlogForMeBlogTue, 29 Jul 2014 08:49:00 GMThttp://www.aygfsteel.com/feng0801/archive/2014/07/29/416297.htmlhttp://www.aygfsteel.com/feng0801/comments/416297.htmlhttp://www.aygfsteel.com/feng0801/archive/2014/07/29/416297.html#Feedback0http://www.aygfsteel.com/feng0801/comments/commentRss/416297.htmlhttp://www.aygfsteel.com/feng0801/services/trackbacks/416297.html阅读全文

ForMeBlog 2014-07-29 16:49 发表评论
]]>
վ֩ģ壺 | | | | | ׷| | ʦ| ɽ| | ԭ| ƺ| | ƽ| | | μ| | | | | ͨ| | | Ϫ| | | | Դ| | ¯| | | Դ| ݳ| ̫| ʯ| н| | | ʯ|