??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久久久久久一,日韩一区二区三区精品视频,污污的网站在线看http://www.aygfsteel.com/paulwong/category/11300.htmlzh-cnFri, 20 May 2022 01:15:01 GMTFri, 20 May 2022 01:15:01 GMT60openJDK无法q行jmaphttp://www.aygfsteel.com/paulwong/archive/2022/05/19/450751.htmlpaulwongpaulwongThu, 19 May 2022 05:53:00 GMThttp://www.aygfsteel.com/paulwong/archive/2022/05/19/450751.htmlhttp://www.aygfsteel.com/paulwong/comments/450751.htmlhttp://www.aygfsteel.com/paulwong/archive/2022/05/19/450751.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/450751.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/450751.htmlhttps://blog.csdn.net/qq_32447301/article/details/85109014


paulwong 2022-05-19 13:53 发表评论
]]>
API接口中的敏感数据的加密与解密http://www.aygfsteel.com/paulwong/archive/2022/05/11/450742.htmlpaulwongpaulwongWed, 11 May 2022 06:37:00 GMThttp://www.aygfsteel.com/paulwong/archive/2022/05/11/450742.htmlhttp://www.aygfsteel.com/paulwong/comments/450742.htmlhttp://www.aygfsteel.com/paulwong/archive/2022/05/11/450742.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/450742.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/450742.html阅读全文

paulwong 2022-05-11 14:37 发表评论
]]>
免注册JDK下蝲http://www.aygfsteel.com/paulwong/archive/2021/08/25/435953.htmlpaulwongpaulwongWed, 25 Aug 2021 08:17:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/08/25/435953.htmlhttp://www.aygfsteel.com/paulwong/comments/435953.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/08/25/435953.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435953.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435953.htmlhttps://repo.huaweicloud.com/java/jdk/



paulwong 2021-08-25 16:17 发表评论
]]>
JSR-303 Bean Validation - @Size和@Max@Min的区?/title><link>http://www.aygfsteel.com/paulwong/archive/2021/04/29/435867.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Thu, 29 Apr 2021 01:55:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2021/04/29/435867.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435867.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2021/04/29/435867.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435867.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435867.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: var(--s-prose-spacing); margin-left: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; box-sizing: inherit; clear: both; color: #242729; background-color: #ffffff;"><code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Min</code> and <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Max</code> are used for validating numeric fields which could be <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">String</code>(representing number), <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">int</code>, <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">short</code>, <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">byte</code> etc and their respective primitive wrappers.<br /><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: var(--s-prose-spacing); margin-left: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; box-sizing: inherit; clear: both; color: #242729; background-color: #ffffff;"><code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Size</code> is used to check the length constraints on the fields.<br /><br /></p><p style="margin: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; box-sizing: inherit; clear: both; color: #242729; background-color: #ffffff;">As per documentation <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Size</code> supports <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">String</code>, <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">Collection</code>, <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">Map</code> and <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">arrays</code> while <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Min</code> and <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Max</code> supports primitives and their wrappers. See the <a rel="noreferrer" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; box-sizing: inherit; cursor: pointer; user-select: auto;">documentation</a>.</p><img src ="http://www.aygfsteel.com/paulwong/aggbug/435867.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2021-04-29 09:55 <a href="http://www.aygfsteel.com/paulwong/archive/2021/04/29/435867.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java泛型 Ҏ(gu)q回值带有泛?<T>http://www.aygfsteel.com/paulwong/archive/2021/03/19/435828.htmlpaulwongpaulwongFri, 19 Mar 2021 07:10:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/03/19/435828.htmlhttp://www.aygfsteel.com/paulwong/comments/435828.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/03/19/435828.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435828.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435828.html

        /**
         * 
         * 
@param <T>声明此方法持有一个类型TQ也可以理解为声明此Ҏ(gu)为泛型方?br />         * @param clazz 作用是指明泛型T的具体类?br />         * @return 指明该方法的q回gؓcdT
         * 
@throws InstantiationException
         * 
@throws IllegalAccessException
         
*/
        public <T> T getObject(Class<T> clazz) throws InstantiationException, IllegalAccessException {
            T t = clazz.newInstance();//创徏对象
            return t;
        }

Ҏ(gu)q回值前?lt;T>的左x告诉~译器,当前的方法的g入类型可以和cd始化的泛型类不同Q也是该方法的泛型cd以自定义Q不需要跟cd始化的泛型类相同



paulwong 2021-03-19 15:10 发表评论
]]>
JSR-303 Bean Validation - Date String Validation http://www.aygfsteel.com/paulwong/archive/2021/02/25/435810.htmlpaulwongpaulwongThu, 25 Feb 2021 01:44:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435810.htmlhttp://www.aygfsteel.com/paulwong/comments/435810.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435810.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435810.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435810.html其实可以新加一个方法返回DatecdQ再配合@Future@Past q行验证?br />
@Future(message = "Invalid CN_ID_INFO.EXPIRE_DATE.")
private LocalDate getValidExpireDate() {
    try {
        return LocalDate.parse(this.dateString, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    } catch (Exception e) {
        return null;
    }
}

此方法对dateStringq行解释Q返回LocalDateQ如果dateString为空或格式错误,则返回空Q再配合@Future q行是否未来日期的验证?br />


paulwong 2021-02-25 09:44 发表评论
]]>
JSR-303 Bean Validation - Conditional Validationhttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435809.htmlpaulwongpaulwongThu, 25 Feb 2021 01:24:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435809.htmlhttp://www.aygfsteel.com/paulwong/comments/435809.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435809.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435809.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435809.htmlq种Ҏ(gu)避免了自定义校验器而增加类?br />https://www.chkui.com/article/java/java_bean_validation

@AssertTrue(message = "Missing BANK_CARD_IMG_INFO.IMG")
private Boolean getValidImg() {
    if(YNEnum.Y.code.equals(super.getNeedChecked())) {
            return StringUtils.hasText(this.img);
        }
        return null;//igore checking.
}

q个是当needChecked为Y的时候才执行查img变量是否为空?br />有几Ҏ(gu)意:
  1. Ҏ(gu)名称要以get开?br />
  2. q回cd用BooleanQ而不用boolean
  3. q回值有三种Qtrue,false,null如果是null则当成通过Q与true的结果一?/li>


paulwong 2021-02-25 09:24 发表评论
]]>
Java8中文件{Base64和Base64转文?/title><link>http://www.aygfsteel.com/paulwong/archive/2021/01/07/435767.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Thu, 07 Jan 2021 01:44:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2021/01/07/435767.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435767.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2021/01/07/435767.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435767.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435767.html</trackback:ping><description><![CDATA[有几个项目中Q都需要将囄或者数字证书的文g转ؓBase64Q昨天写代码的时候,发现在jdk8中本含有关于Base64的API?br /><br />从此后不再需要其他的jar包来转换Base64?!!<br /><br />据说是JDK8加入的?br /><br /><br />先是文件{为Base64Q?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: #0000FF; ">public</span> String encryptToBase64(String filePath) {<br />        <span style="color: #0000FF; ">if</span> (filePath == <span style="color: #0000FF; ">null</span>) {<br />            <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">null</span>;<br />        }<br />        <span style="color: #0000FF; ">try</span> {<br />            <span style="color: #0000FF; ">byte</span>[] b = Files.readAllBytes(Paths.get(filePath));<br />            <span style="color: #0000FF; ">return</span> Base64.getEncoder().encodeToString(b);<br />        } <span style="color: #0000FF; ">catch</span> (IOException e) {<br />            e.printStackTrace();<br />        }<br /> <br />        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">null</span>;<br />    }</div><br />Files、PathscLJDK7里加入的Q读取文件不再需要调用IO包里的FileInputStreamQ简单便捗?br />字符串参数filePath是文件的路径?br /><br />首先是将文gL二进制码Q然后通过Base64.getEncoder().encodeToString()Ҏ(gu)二q制码{换ؓBase64倹{?br /><br /><br />然后是将Base64转ؓ文gQ?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: #0000FF; ">public</span> String decryptByBase64(String base64, String filePath) {<br />        <span style="color: #0000FF; ">if</span> (base64 == <span style="color: #0000FF; ">null</span> && filePath == <span style="color: #0000FF; ">null</span>) {<br />            <span style="color: #0000FF; ">return</span> "生成文gp|Q请l出相应的数据?;<br />        }<br />        <span style="color: #0000FF; ">try</span> {<br />            Files.write(Paths.get(filePath), Base64.getDecoder().decode(base64),StandardOpenOption.CREATE);<br />        } <span style="color: #0000FF; ">catch</span> (IOException e) {<br />            e.printStackTrace();<br />        }<br />        <span style="color: #0000FF; ">return</span> "指定路径下生成文件成功!";<br />    }</div><br />字符串参数base64指的是文件的Base64|filePath是指的文件将要保存的位置?br />通过Files.write()Ҏ(gu)L文件写入指定位|,不再调用FileOutStreamҎ(gu)?br /><br />W三个参数StandardOpenOption.CREATE是处理文件的方式Q我讄的是不管路径下有或没有,都创个文Ӟ有则覆盖?br /><br />在StandardOpenOptioncM有很多参数可调用Q不再篏赘?img src ="http://www.aygfsteel.com/paulwong/aggbug/435767.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2021-01-07 09:44 <a href="http://www.aygfsteel.com/paulwong/archive/2021/01/07/435767.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>开始日期与l束日期的用?/title><link>http://www.aygfsteel.com/paulwong/archive/2020/12/29/435759.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 29 Dec 2020 02:37:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2020/12/29/435759.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435759.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2020/12/29/435759.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435759.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435759.html</trackback:ping><description><![CDATA[通常要用到取某个旉D内的数据,那么旉D要如何定义Q?br /> ?020-12-01q天的数据,"2020-12-01 00:00:00" <= time < "2020-12-02 00:00:00"?br /> apache common3中提供了相应的方法:<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 />-->startDate = DateUtils.parseDate(startDateStr, DATE_PATTERN);<br />            <br />String endDateStr = args.getOptionValues(END_DATE).get(0);<br />endDate = DateUtils.parseDate(endDateStr, DATE_PATTERN);<br /><br /><span style="color: #008000; ">//</span><span style="color: #008000; ">清零开始日期,q回cM2020-12-01 00:00:00            </span><span style="color: #008000; "><br /></span>startDate = DateUtils.truncate(startDate, Calendar.DATE);<br /><span style="color: #008000; ">//</span><span style="color: #008000; ">取结束日期的上限Q返回隔天的旉Q?020-12-02 00:00:00</span><span style="color: #008000; "><br /></span>endDate = DateUtils.ceiling(endDate, Calendar.DATE);"?br />apache common3中提供了相应的方法:</div><img src ="http://www.aygfsteel.com/paulwong/aggbug/435759.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2020-12-29 10:37 <a href="http://www.aygfsteel.com/paulwong/archive/2020/12/29/435759.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java的BIO和NIO很难懂?用代码实늻你看Q再不懂我{行!http://www.aygfsteel.com/paulwong/archive/2020/12/02/435737.htmlpaulwongpaulwongWed, 02 Dec 2020 00:52:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/12/02/435737.htmlhttp://www.aygfsteel.com/paulwong/comments/435737.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/12/02/435737.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435737.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435737.htmlhttp://www.52im.net/thread-2846-1-1.html



paulwong 2020-12-02 08:52 发表评论
]]>
Pretty print JSON using org.json library in Javahttp://www.aygfsteel.com/paulwong/archive/2020/10/28/435709.htmlpaulwongpaulwongWed, 28 Oct 2020 09:17:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/10/28/435709.htmlhttp://www.aygfsteel.com/paulwong/comments/435709.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/10/28/435709.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435709.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435709.htmlSyntax
public java.lang.String toString(int indentFactor) throws JSONException

Example

import org.json.*;
public class JSONPrettyPrintTest {
   
public static void main(String args[]) throws JSONException {
      String json 
= "{" +
                    
"Name : Jai," +
                    
"Age : 25, " +
                    
"Salary: 25000.00 " +
                    
"}";
      JSONObject jsonObj 
= new JSONObject(json);
      System.out.println(
"Pretty Print of JSON:");
      System.out.println(jsonObj.toString(
4)); // pretty print json
   }
}

Output

Pretty Print of JSON:
{
   "Salary": 25000,
   "Age": 25,
   "Name": "Jai"
}


paulwong 2020-10-28 17:17 发表评论
]]>
Scheduling a task in Java within a CompletableFuturehttp://www.aygfsteel.com/paulwong/archive/2020/08/24/435646.htmlpaulwongpaulwongMon, 24 Aug 2020 01:06:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/08/24/435646.htmlhttp://www.aygfsteel.com/paulwong/comments/435646.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/08/24/435646.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435646.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435646.htmlWhen we want to do something later in our Java code, we often turn to the ScheduledExecutorService. This class has a method called schedule(), and we can pass it some code to be run later like this:

ScheduledExecutorService executor =
    Executors.newScheduledThreadPool(4);
executor.schedule(
    () -> {System.out.println("..later");},
    1,
    TimeUnit.SECONDS
);
System.out.println("do");
// (Don't forget to shut down the executor later)

The above code prints “do…” and then one second later it prints “…later”.

We can even write code that does some work and returns a result in a similar way:

// (Make the executor as above.)
ScheduledFuture future = executor.schedule(
    () -> 10 + 25, 1, TimeUnit.SECONDS);
System.out.println("answer=" + future.get())


The above code prints “answer=35”. When we call get() it blocks waiting for the scheduler to run the task and mark the ScheduledFuture as complete, and then returns the answer to the sum (10 + 25) when it is ready.

This is all very well, but you may note that the Future returned from schedule() is a ScheduledFuture, and a ScheduledFuture is not a CompletableFuture.

Why do you care? Well, you might care if you want to do something after the scheduled task is completed. Of course, you can call get(), and block, and then do something, but if you want to react asynchronously without blocking, this won’t work.

The normal way to run some code after a Future has completed is to call one of the “then*” or “when*” methods on the Future, but these methods are only available on CompletableFuture, not ScheduledFuture.

Never fear, we have figured this out for you. We present a small wrapper for schedule that transforms your ScheduledFuture into a CompletableFuture. Here’s how to use it:

CompletableFuture<Integer> future =
    ScheduledCompletable.schedule(
        executor,
        () -> 10 + 25,
        1,
        TimeUnit.SECONDS
     );
future.thenAccept(
    answer -> {System.out.println(answer);}
);
System.out.println("Answer coming")


The above code prints “Answer coming…” and then “35”, so we can see that we don’t block the main thread waiting for the answer to come back.

So far, we have scheduled a synchronous task to run in the background after a delay, and wrapped its result in a CompletableFuture to allow us to chain more tasks after it.

In fact, what we often want to do is schedule a delayed task that is itself asynchronous, and already returns a CompletableFuture. In this case it feels particularly natural to get the result back as a CompletableFuture, but with the current ScheduledExecutorService interface we can’t easily do it.

It’s OK, we’ve figured that out too:

Supplier<CompletableFuture<Integer>> asyncTask = () ->
    CompletableFuture.completedFuture(10 + 25);
CompletableFuture<Integer> future =
    ScheduledCompletable.scheduleAsync(
        executor, asyncTask, 1, TimeUnit.SECONDS);
future.thenAccept(
    answer -> {System.out.println(answer);}
);
System.out.println("Answer coming")


The above code prints “Answer coming…” and then “35”, so we can see that our existing asynchronous task was scheduled in the background, and we didn’t have to block the main thread waiting for it. Also, under the hood, we are not blocking the ScheduledExecutorService‘s thread (from its pool) while the async task is running – that task just runs in whatever thread it was assigned when it was created. (Note: in our example we don’t really run an async task at all, but just immediately return a completed Future, but this does work for real async tasks.)

I know you’re wondering how we achieved all this. First, here’s how we run a simple blocking task in the background and wrap it in a CompletableFuture:

public static <T> CompletableFuture<T> schedule(
    ScheduledExecutorService executor,
    Supplier<T> command,
    long delay,
    TimeUnit unit
) {
    CompletableFuture<T> completableFuture = new CompletableFuture<>();
    executor.schedule(
        (() -> {
            try {
                return completableFuture.complete(command.get());
            } catch (Throwable t) {
                return completableFuture.completeExceptionally(t);
            }
        }),
        delay,
        unit
    );
    return completableFuture;
}


And here’s how we delay execution of an async task but still return its result in a CompletableFuture:

public static <T> CompletableFuture<T> scheduleAsync(
    ScheduledExecutorService executor,
    Supplier<CompletableFuture<T>> command,
    long delay,
    TimeUnit unit
) {
    CompletableFuture<T> completableFuture = new CompletableFuture<>();
    executor.schedule(
        (() -> {
            command.get().thenAccept(
                t -> {completableFuture.complete(t);}
            )
            .exceptionally(
                t -> {completableFuture.completeExceptionally(t);return null;}
            );
        }),
        delay,
        unit
    );
    return completableFuture;
}


Note that this should all work to run methods like exceptionally()thenAccept()whenComplete() etc.

Feedback and improvements welcome!


https://www.artificialworlds.net/blog/2019/04/05/scheduling-a-task-in-java-within-a-completablefuture/

paulwong 2020-08-24 09:06 发表评论
]]>
CompletableFuturehttp://www.aygfsteel.com/paulwong/archive/2020/08/14/435641.htmlpaulwongpaulwongFri, 14 Aug 2020 03:46:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/08/14/435641.htmlhttp://www.aygfsteel.com/paulwong/comments/435641.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/08/14/435641.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435641.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435641.html
Thread t1 = new Thread();
Thread t2 = new Thread();
t1.start(); // 启动新线E?/span>
t2.start(); // 启动新线E?/span>

׃创徏和销毁线E是非常耗资源,因此Ҏ(gu)U程建好后不销毁,可以重用Q用户只需提供runҎ(gu)的具体实玎ͼ
public static void main(String[] args) throws Exception {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        Future<String> stringFuture = executor.submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                Thread.sleep(2000);
                return "async thread";
            }
        });
        Thread.sleep(1000);
        System.out.println("main thread");
        System.out.println(stringFuture.get());

    }

但如果很多线E被创徏Qƈ且线E间有依赖,x程和条件执行线E,实现h有点复杂,于是CompletableFuture横空Z。一共有50各方法可供用?br />
CompletableFuture.supplyAsync()Q相当于创徏了ExecutorServiceQ同时也创徏了CallableQ然后提交到U程池中执行?/div>
CompletableFuture<String> futureA = CompletableFuture.supplyAsync(() -> "dA");
CompletableFuture<String> futureB = CompletableFuture.supplyAsync(() -> "dB");
CompletableFuture<String> futureC = futureB.thenApply(b -> {
      System.out.println("执行dC.");
      System.out.println("参数:" + b);//参数:dB
      return "a";
});


!!How to use CompletableFuture and Callable in Java
https://ducmanhphan.github.io/2020-02-10-How-to-use-CompletableFuture-Callable-in-Java/

使用CompletableFuture优化你的代码执行效率
https://www.cnblogs.com/fingerboy/p/9948736.html

CompletableFuture 使用详解
https://www.jianshu.com/p/6bac52527ca4

使用CompletableFuture
https://www.liaoxuefeng.com/wiki/1252599548343744/1306581182447650


https://github.com/eugenp/tutorials/blob/master/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java

paulwong 2020-08-14 11:46 发表评论
]]>Springboot+proguard+maven hhttp://www.aygfsteel.com/paulwong/archive/2020/08/13/435639.htmlpaulwongpaulwongThu, 13 Aug 2020 02:53:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/08/13/435639.htmlhttp://www.aygfsteel.com/paulwong/comments/435639.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/08/13/435639.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435639.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435639.htmlhttps://blog.csdn.net/qq_35981283/article/details/78529929



paulwong 2020-08-13 10:53 发表评论
]]>
Different ways to create objects in Javahttp://www.aygfsteel.com/paulwong/archive/2020/08/07/435631.htmlpaulwongpaulwongFri, 07 Aug 2020 02:04:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/08/07/435631.htmlhttp://www.aygfsteel.com/paulwong/comments/435631.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/08/07/435631.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435631.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435631.htmlhttps://www.geeksforgeeks.org/different-ways-create-objects-java/




paulwong 2020-08-07 10:04 发表评论
]]>
为啥文g的CHECKSUM中SHA512比MD5高Q?/title><link>http://www.aygfsteel.com/paulwong/archive/2020/06/16/435513.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 16 Jun 2020 02:21:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2020/06/16/435513.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435513.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2020/06/16/435513.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435513.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435513.html</trackback:ping><description><![CDATA[<a target="_blank">https://stackoverflow.com/questions/2117732/reasons-why-sha512-is-superior-to-md5</a><br /><img src ="http://www.aygfsteel.com/paulwong/aggbug/435513.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2020-06-16 10:21 <a href="http://www.aygfsteel.com/paulwong/archive/2020/06/16/435513.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>各种获取JVM DUMP的方?/title><link>http://www.aygfsteel.com/paulwong/archive/2020/02/24/435157.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Mon, 24 Feb 2020 14:03:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2020/02/24/435157.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435157.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2020/02/24/435157.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435157.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435157.html</trackback:ping><description><![CDATA[<p style="font-size: medium; font-family: "Times New Roman";">JVM 的线E堆?dump 也称 core dumpQ内容ؓ文本Q主要包含当?JVM 的线E堆栈,?dump 也称 heap dumpQ内容ؓ二进制格式,主要包含当时 JVM 堆内存中的内宏V由于各个操作系l、各?JVM 实现不同Q即使同一 JVM 实现Q各个版本也有差异,本文描述的方法都Z 64 ?Linux 操作pȝ环境QJava 8 Oracle HotSpot JVM 实现?/p><p style="font-size: medium; font-family: "Times New Roman";">堆栈和堆的内容在定位问题的时候,都是非常重要的信息。线E堆?dump 可以了解当时 JVM 中所有线E的q行情况Q比如线E的状态和当前正在q行的代码行。堆 dump 可以了解当时堆的使用情况Q各个类实例的数量及各个实例所占用的空间大?/p><h1>U程堆栈</h1><h2>使用 jstack</h2><p style="font-size: medium; font-family: "Times New Roman";">jstack ?JDK 自带的工P用于 dump 指定q程 ID(PID)?JVM 的线E堆栈信息?/p><div highlighter-rouge"="" style="font-size: medium; font-family: "Times New Roman";"><pre><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 />--># 打印堆栈信息到标准输?nbsp;jstack PID  <br /># 打印堆栈信息到标准输出,会打印关于锁的信?nbsp;jstack -l PID  <br />强制打印堆栈信息到标准输出,如果使用 jstack PID 没有响应的情况下(此时 JVM q程可能挂v)Q?br />?nbsp;-F 参数 jstack -F PID </div></pre></div><h2>使用 jcmd</h2><p style="font-size: medium; font-family: "Times New Roman";">jcmd ?JDK 自带的工P用于?JVM q程发送命令,Ҏ(gu)命o的不同,可以代替或部分代?jstack、jmap {。可以发送命?nbsp;<code>Thread.print</code> 来打印出 JVM 的线E堆栈信息?/p><div highlighter-rouge"="" style="font-size: medium; font-family: "Times New Roman";"><pre><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 />--># 下面的命令同{于 jstack PID <br />jcmd PID Thread.print  <br /><br /># 同等?nbsp;jstack -l PID <br />jcmd PID Thread.print -l </div></pre></div><h2>使用 kill -3</h2><p style="font-size: medium; font-family: "Times New Roman";">kill 可以向特定的q程发送信?SIGNAL)Q缺省情冉|发送终?TERM) 的信?Q即 kill PID ?kill -15 PID ?kill -TERM PID 是等L。JVM q程会监?QUIT 信号(其gؓ 3)Q当收到q个信号Ӟ会打印出当时的线E堆栈和堆内存用概要,相比 jstackQ此时多了堆内存的用概要情c但 jstack 可以指定 -l 参数Q打印锁的信息?/p><div highlighter-rouge"="" style="font-size: medium; font-family: "Times New Roman";"><pre><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 />-->kill -3 PID <br /># ?nbsp;kill -QUIT PID </div></pre></div><h1>?/h1><h2>-XX:+HeapDumpOnOutOfMemoryError</h2><p style="font-size: medium; font-family: "Times New Roman";">d JVM 参数 -XX:+HeapDumpOnOutOfMemoryError 后,当发?OOM(OutOfMemory)Ӟ自动?dump。缺省情况下QJVM 会创Z个名UCؓ java_pidPID.hprof 的堆 dump 文g?JVM 的工作目录下。但可以使用参数 -XX:HeapDumpPath=PATH 来指?dump 文g的保存位|?/p><div highlighter-rouge"="" style="font-size: medium; font-family: "Times New Roman";"><pre><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 />--># JVM 发生 OOM Ӟ会自动在 /var/log/abc 目录下生堆 dump 文g java_pidPID.hprof <br />java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/abc/ </div></pre></div><h2>jmap</h2><p style="font-size: medium; font-family: "Times New Roman";">jmap 也是 JDK 自带的工P主要用于获取堆相关的信息?/p><h3>?dump</h3><div highlighter-rouge"="" style="font-size: medium; font-family: "Times New Roman";"><pre><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 />--># ?nbsp;JVM 的堆 dump 到指定文Ӟ如果堆中对象较多Q需要的旉会较长,子参?nbsp;format 只支?nbsp;bQ?br />即二q制格式<br />jmap -dump:format=b,file=FILE_WITH_PATH<br /><br /># 如果 JVM q程未响应命令,可以加上参数 -F 试<br />jmap -F -dump:format=b,file=FILE_WITH_PATH<br /><br /># 可以?nbsp;dump 堆中的存?gu)zd象,加上 live 子参敎ͼ但?nbsp;-F 时不支持 live<br />jmap -dump:live,format=b,file=FILE_WITH_PATH</div></pre></div><h3>获取堆概要信?/h3><div highlighter-rouge"="" style="font-size: medium; font-family: "Times New Roman";"><pre><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 />--># -heap 参数用于查看指定 JVM q程的堆的信息,包括堆的各个参数的|堆中新生代、年老代的内存大、用率{?nbsp;<br />jmap -heap PID  <br /><br /># 同样Q如?nbsp;JVM q程未响应命令,可以加上参数 -F 试 <br />jmap -F -heap PID </div></pre></div><p style="font-size: medium; font-family: "Times New Roman";">一个实例输出如下:</p><div style="font-size: medium; font-family: "Times New Roman";"><pre><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 />-->Attaching to process ID 68322, please wait<img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /><br />Debugger attached successfully.<br />Server compiler detected.<br />JVM version is 25.112-b16<br /><br />using thread-local object allocation.<br />Parallel GC with 4 thread(s)<br /><br />Heap Configuration:<br />   MinHeapFreeRatio         = 0<br />   MaxHeapFreeRatio         = 100<br />   MaxHeapSize              = 268435456 (256.0MB)<br />   NewSize                  = 8388608 (8.0MB)<br />   MaxNewSize               = 89128960 (85.0MB)<br />   OldSize                  = 16777216 (16.0MB)<br />   NewRatio                 = 2<br />   SurvivorRatio            = 8<br />   MetaspaceSize            = 21807104 (20.796875MB)<br />   CompressedClassSpaceSize = 1073741824 (1024.0MB)<br />   MaxMetaspaceSize         = 17592186044415 MB<br />   G1HeapRegionSize         = 0 (0.0MB)<br /><br />Heap Usage:<br />PS Young Generation<br />Eden Space:<br />   capacity = 41943040 (40.0MB)<br />   used     = 1701504 (1.6226806640625MB)<br />   free     = 40241536 (38.3773193359375MB)<br />   4.05670166015625% used<br />From Space:<br />   capacity = 4194304 (4.0MB)<br />   used     = 0 (0.0MB)<br />   free     = 4194304 (4.0MB)<br />   0.0% used<br />To Space:<br />   capacity = 5242880 (5.0MB)<br />   used     = 0 (0.0MB)<br />   free     = 5242880 (5.0MB)<br />   0.0% used<br />PS Old Generation<br />   capacity = 30408704 (29.0MB)<br />   used     = 12129856 (11.56793212890625MB)<br />   free     = 18278848 (17.43206787109375MB)<br />   39.889421134159484% used<br /><br />16658 interned Strings occupying 1428472 bytes.</div><span style="font-family: verdana, "courier new"; font-size: 14px;"><br />获取堆中的类实例l计</span></pre></div><div highlighter-rouge"="" style="font-size: medium; font-family: "Times New Roman";"><pre><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 />--># 打印 JVM 堆中的类实例l计信息Q以占用内存的大排序,同样Q如?nbsp;JVM 未响应命令,也可以?nbsp;-F 参数 <br />jmap -histo PID  <br /><br /># 也可以只l计堆中的存?gu)zd象,加上 live 子参敎ͼ但?nbsp;-F 时不支持 live <br />jmap -histo:live PID </div></pre></div><h2>使用 jcmd</h2><div highlighter-rouge"="" style="font-size: medium; font-family: "Times New Roman";"><pre><div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--># {同 jmap -dump:live,format=b,file=FILE_WITH_PATH<br />jcmd PID GC.heap_dump FILE_WITH_PATH<br /><br /># {同 jmap -dump:format=b,file=FILE_WITH_PATH<br />jcmd PID GC.heap_dump -all FILE_WITH_PATH<br /><br /># {同 jmap -histo:live PID<br />jcmd PID GC.class_histogram<br /><br /># {同 jmap -histo PID<br />jcmd PID GC.class_histogram -all</div></pre></div><img src ="http://www.aygfsteel.com/paulwong/aggbug/435157.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2020-02-24 22:03 <a href="http://www.aygfsteel.com/paulwong/archive/2020/02/24/435157.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CountDownLatch、CyclicBarrier和Semaphorehttp://www.aygfsteel.com/paulwong/archive/2019/09/24/434696.htmlpaulwongpaulwongTue, 24 Sep 2019 02:18:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/09/24/434696.htmlhttp://www.aygfsteel.com/paulwong/comments/434696.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/09/24/434696.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/434696.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/434696.htmlCountDownLatch、CyclicBarrier和Semaphoreq三个ƈ发辅助类Q可以在U程中呼叫,使得U程暂停{,但各有不同?br />
  • CountDownLatch
1、初始化Qƈ传入计数?br /> 2、向不同的线E传入CountDownLatch实例
3、如果在某一U程中呼叫await()Q则此线E被挂vQ直到计数器?Q才往下执?br /> 4、如果在某一U程中呼叫countDown()Q计数器?
5、最l如果计数器gؓ0Ӟ则CountDownLatch实例不再起作用了Q即Zơ性的

  • CyclicBarrier
1、初始化Qƈ传入计数器|也可传入一个Runnablec,会在计数器ؓ0Ӟ被执?br /> 2、向不同的线E传入CyclicBarrier实例
3、如果在某一U程中呼叫await()Q则此线E被挂vQ直到计数器?Q才往下执?br /> 4、其他线E呼叫await()Q则此线E被挂vQ直到计数器?Q才往下执?br /> 5、最l如果计数器gؓ0Ӟ则CyclicBarrier实例会将计数器值恢复,又可重用

  • Semaphore
1、初始化Qƈ传入计数器?br /> 2、向不同的线E传入Semaphore实例
3、如果在某一U程中呼叫acquire()Q则Semaphore实例会将计数器值减1Q如果计数器gؓ-1Q则计数器值置?Q此U程被挂P直到计数器值大?Ӟ才往下执?br /> 4、此U程需呼叫release()Q得计数器?1Q以便其他线E在计数器gؓ0时不受阻


CountDownLatch 例子Q?br />
public class Test {
     public static void main(String[] args) {   
         final CountDownLatch latch = new CountDownLatch(2);
          
         new Thread(){
             public void run() {
                 try {
                     System.out.println("子线E?+Thread.currentThread().getName()+"正在执行");
                    Thread.sleep(3000);
                    System.out.println("子线E?+Thread.currentThread().getName()+"执行完毕");
                    latch.countDown();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
             };
         }.start();
          
         new Thread(){
             public void run() {
                 try {
                     System.out.println("子线E?+Thread.currentThread().getName()+"正在执行");
                     Thread.sleep(3000);
                     System.out.println("子线E?+Thread.currentThread().getName()+"执行完毕");
                     latch.countDown();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
             };
         }.start();
          
         try {
             System.out.println("{待2个子U程执行完毕");
            latch.await();
            System.out.println("2个子U程已经执行完毕");
            System.out.println("l箋执行ȝE?);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
     }
}

l果Q?br />
U程Thread-0正在执行
U程Thread-1正在执行
{待2个子U程执行完毕
U程Thread-0执行完毕
U程Thread-1执行完毕
2个子U程已经执行完毕
l箋执行ȝE?/div>

CyclicBarrier例子Q?br />
public class Test {
    public static void main(String[] args) {
        int N = 4;
        CyclicBarrier barrier  = new CyclicBarrier(N,new Runnable() {
            @Override
            public void run() {
                System.out.println("当前U程"+Thread.currentThread().getName());   
            }
        });
         
        for(int i=0;i<N;i++)
            new Writer(barrier).start();
    }
    static class Writer extends Thread{
        private CyclicBarrier cyclicBarrier;
        public Writer(CyclicBarrier cyclicBarrier) {
            this.cyclicBarrier = cyclicBarrier;
        }
 
        @Override
        public void run() {
            System.out.println("U程"+Thread.currentThread().getName()+"正在写入数据");
            try {
                Thread.sleep(5000);      //以睡眠来模拟写入数据操作
                System.out.println("U程"+Thread.currentThread().getName()+"写入数据完毕Q等待其他线E写入完?);
                cyclicBarrier.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }catch(BrokenBarrierException e){
                e.printStackTrace();
            }
            System.out.println("所有线E写入完毕,l箋处理其他d");
        }
    }
}

执行l果Q?br />
U程Thread-0正在写入数据
U程Thread-1正在写入数据
U程Thread-2正在写入数据
U程Thread-3正在写入数据
U程Thread-0写入数据完毕Q等待其他线E写入完?br /> U程Thread-1写入数据完毕Q等待其他线E写入完?br /> U程Thread-2写入数据完毕Q等待其他线E写入完?br /> U程Thread-3写入数据完毕Q等待其他线E写入完?br /> 当前U程Thread-3
所有线E写入完毕,l箋处理其他d
所有线E写入完毕,l箋处理其他d
所有线E写入完毕,l箋处理其他d
所有线E写入完毕,l箋处理其他d


Semaphore例子Q?br />
public class Test {
    public static void main(String[] args) {
        int N = 8;            //工h?/span>
        Semaphore semaphore = new Semaphore(5); //机器数目
        for(int i=0;i<N;i++)
            new Worker(i,semaphore).start();
    }
     
    static class Worker extends Thread{
        private int num;
        private Semaphore semaphore;
        public Worker(int num,Semaphore semaphore){
            this.num = num;
            this.semaphore = semaphore;
        }
         
        @Override
        public void run() {
            try {
                semaphore.acquire();
                System.out.println("工h"+this.num+"占用一个机器在生");
                Thread.sleep(2000);
                System.out.println("工h"+this.num+"释放出机?);
                semaphore.release();           
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

执行l果Q?br />
工h0占用一个机器在生
工h1占用一个机器在生
工h2占用一个机器在生
工h4占用一个机器在生
工h5占用一个机器在生
工h0释放出机?br /> 工h2释放出机?br /> 工h3占用一个机器在生
工h7占用一个机器在生
工h4释放出机?br /> 工h5释放出机?br /> 工h1释放出机?br /> 工h6占用一个机器在生
工h3释放出机?br /> 工h7释放出机?br /> 工h6释放出机?/div>
https://www.cnblogs.com/dolphin0520/p/3920397.html

https://juejin.im/post/5aeec3ebf265da0ba76fa327

paulwong 2019-09-24 10:18 发表评论
]]>使用 Awaitility 试异步代码http://www.aygfsteel.com/paulwong/archive/2019/08/01/434327.htmlpaulwongpaulwongThu, 01 Aug 2019 02:06:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/08/01/434327.htmlhttp://www.aygfsteel.com/paulwong/comments/434327.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/08/01/434327.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/434327.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/434327.html自动化工?异步校验工具 awaitility 快速入?/div>https://testerhome.com/topics/7408


https://yanbin.blog/test-asyn-call-with-awaitility/

Introduction to Awaitlity
https://www.baeldung.com/awaitlity-testing






paulwong 2019-08-01 10:06 发表评论
]]>
zip4jhttp://www.aygfsteel.com/paulwong/archive/2019/06/10/433851.htmlpaulwongpaulwongMon, 10 Jun 2019 08:47:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/06/10/433851.htmlhttp://www.aygfsteel.com/paulwong/comments/433851.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/06/10/433851.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/433851.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/433851.htmlhttps://rensanning.iteye.com/blog/1836727



paulwong 2019-06-10 16:47 发表评论
]]>
JAVA 8 TIMEhttp://www.aygfsteel.com/paulwong/archive/2019/05/09/433761.htmlpaulwongpaulwongThu, 09 May 2019 02:15:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/05/09/433761.htmlhttp://www.aygfsteel.com/paulwong/comments/433761.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/05/09/433761.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/433761.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/433761.htmlJava 8新特性(四)Q新的时间和日期API
https://lw900925.github.io/java/java8-newtime-api.html
 

paulwong 2019-05-09 10:15 发表评论
]]>
SHARDING-JDBChttp://www.aygfsteel.com/paulwong/archive/2016/03/29/429870.htmlpaulwongpaulwongTue, 29 Mar 2016 13:26:00 GMThttp://www.aygfsteel.com/paulwong/archive/2016/03/29/429870.htmlhttp://www.aygfsteel.com/paulwong/comments/429870.htmlhttp://www.aygfsteel.com/paulwong/archive/2016/03/29/429870.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/429870.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/429870.htmlhttps://github.com/dangdangdotcom/sharding-jdbc/

paulwong 2016-03-29 21:26 发表评论
]]>
Java 中正?hashCode ?equals Ҏ(gu)http://www.aygfsteel.com/paulwong/archive/2015/12/01/428439.htmlpaulwongpaulwongTue, 01 Dec 2015 02:52:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/12/01/428439.htmlhttp://www.aygfsteel.com/paulwong/comments/428439.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/12/01/428439.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/428439.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/428439.html阅读全文

paulwong 2015-12-01 10:52 发表评论
]]>
javax.crypto.IllegalBlockSizeException: Data must not be longer than 256 bytes 解决办法http://www.aygfsteel.com/paulwong/archive/2015/11/18/428264.htmlpaulwongpaulwongWed, 18 Nov 2015 07:27:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/11/18/428264.htmlhttp://www.aygfsteel.com/paulwong/comments/428264.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/11/18/428264.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/428264.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/428264.html
javax.crypto.IllegalBlockSizeException: Data must not be longer than 256 bytes

推荐的做法:

  1. 随机生成一个密钥,用作对称密钥UUID
  2. 用此对称密钥Q用对称加密法AES加密数据
  3. 用RSA的公钥加密此对称密钥
  4. 发送加密后的对U密钥和加密数据
  5. 用RSAU钥解密加密后的对称密钥
  6. 用解密密后的对称密钥Q解密数?br />
  7. 完成
AESSecurityUtil.java
import java.security.Key;
import java.util.UUID;

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class AESSecurityUtil {

    // 加密法
    /** 指定加密法为RSA */
    private static final String ALGORITHM = "AES";

    // 加密密钥
    
// private static final byte[] keyValue = new byte[] { 'T', 'h', 'e',
    
// 'B','e', 's', 't', 'S', 'e', 'c', 'r', 'e', 't', 'K', 'e', 'y' };
    
// 16位的加密密钥
//    private byte[] keyValue;

    /**
     * 用来q行加密的操?br />      * 
     * 
@param Data
     * 
@return
     * 
@throws Exception
     
*/
    public static String encrypt(String keyString, String data)
            throws Exception {
        Key key = generateKey(keyString);
        Cipher c = Cipher.getInstance(ALGORITHM);
        c.init(Cipher.ENCRYPT_MODE, key);
        byte[] encVal = c.doFinal(data.getBytes());
        String encryptedValue = new BASE64Encoder().encode(encVal);
        return encryptedValue;
    }

    /**
     * 用来q行解密的操?br />      * 
     * 
@param encryptedData
     * 
@return
     * 
@throws Exception
     
*/
    public static String decrypt(String keyString, String encryptedData) throws Exception {
        Key key = generateKey(keyString);
        Cipher c = Cipher.getInstance(ALGORITHM);
        c.init(Cipher.DECRYPT_MODE, key);
        byte[] decordedValue = new BASE64Decoder().decodeBuffer(encryptedData);
        byte[] decValue = c.doFinal(decordedValue);
        String decryptedValue = new String(decValue);
        return decryptedValue;
    }
    
    public static String generateKeyString()
    {
        //必须长度?6
        return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 16);
    }

    /**
     * Ҏ(gu)密钥和算法生成Key
     * 
     * 
@return
     * 
@throws Exception
     
*/
    private static Key generateKey(String keyString) throws Exception {
        Key key = new SecretKeySpec(keyString.getBytes(), ALGORITHM);
        return key;
    }
    
    public static void main(String [] args) throws Exception
    {
        String keyString = generateKeyString();
//        String keyString = "1234567890123456";
        System.out.println("密钥Q? + keyString);
        
        String source = "恭喜发胦!";// 要加密的字符?/span>
        System.out.println("准备用密钥加密的字符串ؓQ? + source);
        
        String cryptograph = encrypt(keyString, source);// 生成的密?/span>
        System.out.print("用密钥加密后的结果ؓ:" + cryptograph);
        System.out.println();

        String target = decrypt(keyString, cryptograph);// 解密密文
        System.out.println("用密钥解密后的字W串为:" + target);
        System.out.println();
    }

}


CryptoUtil.java
import com.tcl.project7.boss.common.crypto.CryptoData;
import com.tcl.project7.boss.common.util.JsonManager;
import com.tcl.project7.boss.common.util.file.FileUtil;
import com.tcl.project7.boss.gameapplication.yearendactivities.bigwheelgame.player.valueobject.BigWheelGameRequest;

public class CryptoUtil {
    
    public static CryptoData encrypt(String data) throws Exception
    {
        //1、生AES密钥
        String keyString = AESSecurityUtil.generateKeyString();
        
        //2、用AES法加密数?/span>
        String cryptograph = AESSecurityUtil.encrypt(keyString, data);
        
        //3、用RSA加密AES密钥
        String finalKey = RSASecurityUtil.encrypt(keyString);
//        System.out.print("用RSA加密AES密钥?" + finalKey);
//        System.out.print("加密数据:" + cryptograph);
        
        CryptoData cryptoData = new CryptoData();
        cryptoData.setKey(finalKey);
        cryptoData.setContent(cryptograph);
        
        //4、返回数?/span>
        return cryptoData;
    }
    
    public static String decrypt(String keyString, String data) throws Exception
    {
        //1、解密密?/span>
        String decryptKeyString = RSASecurityUtil.decrypt(keyString);
        
        //2、解密内?/span>
        String decryptData = AESSecurityUtil.decrypt(decryptKeyString, data);
        
        //3、返?/span>
        return decryptData;
        
    }
    
    public static void main(String [] args) throws Exception
    {
        String aFilePath = "DATA/TESTING-FILE/TOCRYPTO/tocrypto.txt";
        String source = FileUtil.getContents(aFilePath);
        
        CryptoData cryptoData = encrypt(source);
        System.out.print(cryptoData);
        
        String target = decrypt(cryptoData.getKey(), cryptoData.getContent());
        System.out.print(target);
        
        BigWheelGameRequest bigWheelGameRequest = JsonManager.getBean(target, BigWheelGameRequest.class);
        System.out.print(bigWheelGameRequest);
    }

}


CryptoData.java
import java.io.Serializable;

public class CryptoData implements Serializable{

    private static final long serialVersionUID = -4774469372648172844L;
    
    private String key;
    
    private String content;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String toString() {
        return "CryptoData [key=" + key + ", content=" + content + "]";
    }

}



paulwong 2015-11-18 15:27 发表评论
]]>
JSON转JAVA BEANhttp://www.aygfsteel.com/paulwong/archive/2015/11/18/428258.htmlpaulwongpaulwongWed, 18 Nov 2015 05:30:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/11/18/428258.htmlhttp://www.aygfsteel.com/paulwong/comments/428258.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/11/18/428258.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/428258.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/428258.html
import java.io.IOException;

import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class ColumnControllerTest {
    
    private Logger logger = LoggerFactory.getLogger(ColumnControllerTest.class);
    
    
    @Test
    public void testTest()
    {
        ObjectMapper mapper = new ObjectMapper();
        /*AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
        // make deserializer use JAXB annotations (only)
        mapper.getDeserializationConfig().setAnnotationIntrospector(introspector);
        // make serializer use JAXB annotations (only)
        mapper.getSerializationConfig().setAnnotationIntrospector(introspector);
*/
        mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        
        String userStr = "{\"username\":\"paul\",\"email\":\"paul@paul.com\"}";
        try {
            TypeReference<TestUser> temp = new TypeReference<TestUser>(){};
            TestUser testUser = mapper.readValue(userStr, temp);
            System.out.println(testUser.toString());
            
            String result = mapper.writeValueAsString(testUser);
            System.out.println(result);
            
        } catch (JsonParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (JsonMappingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}


paulwong 2015-11-18 13:30 发表评论
]]>
Java NIO核心概念及基本读?/title><link>http://www.aygfsteel.com/paulwong/archive/2015/05/10/424980.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Sun, 10 May 2015 12:55:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2015/05/10/424980.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/424980.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2015/05/10/424980.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/424980.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/424980.html</trackback:ping><description><![CDATA[     摘要: 面向的I/Opȝ一ơ一个字节地处理数据。一个输入流产生一个字节的数据Q一个输出流消费一个字节的数据。ؓ式数据创徏qo器非常容易。链接几个过滤器Q以便每个过滤器只负责单个复杂处理机制的一部分Q这样也是相对简单的。不利的一面是Q面向流的I/O通常相当慢?nbsp;   NIO与原来的I/O有同L作用和目的,但是它用块I/O的处理方式。每一个操作都在一步中产生或者消费一个数...  <a href='http://www.aygfsteel.com/paulwong/archive/2015/05/10/424980.html'>阅读全文</a><img src ="http://www.aygfsteel.com/paulwong/aggbug/424980.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2015-05-10 20:55 <a href="http://www.aygfsteel.com/paulwong/archive/2015/05/10/424980.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>开源中?2014 最受关注开源Y件排行榜 TOP 50http://www.aygfsteel.com/paulwong/archive/2015/01/07/422097.htmlpaulwongpaulwongTue, 06 Jan 2015 16:08:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/01/07/422097.htmlhttp://www.aygfsteel.com/paulwong/comments/422097.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/01/07/422097.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/422097.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/422097.html

开源中?2014 q最受关注Y件排行榜 TOP 50 正式出炉Q?014 q结束了Q我们来了解一下过Mq里开源中国最受欢q的 50 ƾY件。此榜单是根据过Mq的用户讉K、交分享和目本n的更新频度等诸多角度Ҏ(gu)录于开源中?33000+ Ƒּ源Y件进行统计,从而得出前 50 名最受欢q的开源YӞ仅供参考?/p>

本排行榜主要是针对开源中国社区在 2014 q度最受欢q的 50 Ƅ门开源项目根据用戯问量、讨论和x{角度进行筛选,从而得出前 50 名开源Y件列表:

1. JFinal

JFinal 是基?Java 语言的极?WEB + ORM 框架Q其核心设计目标是开发迅速、代码量、学习简单、功能强大、轻量、易扩展、Restful。在拥有Java语言所有优势的同时再拥有ruby、python、php{动态语a的开发效率!

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://git.oschina.net/jfinal/jfinal

2. AngularJS

Angular JS (Angular.JS) 是一l用来开发Web面的框架、模板以及数据绑定和丰富UIlg。它支持整个开发进E,提供web应用的架构,无需q行手工DOM操作?AngularJS很小Q只?0KQ兼容主浏览器Q与 jQuery 配合良好?/p>

授权协议QMIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/angular/angular.js

3.  Bootstrap

Bootstrap是快速开发Web应用E序的前端工具包。它是一个CSS和HTML的集合,它用了最新的览器技术,l你的Web开发提供了时尚的版式,表单QbuttonsQ表||格pȝ{等?/p>

授权协议QMIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/twbs/bootstrap

4.  Dubbo

Dubbo 是阿里巴巴公司开源的一个高性能优秀的服务框Ӟ使得应用可通过高性能?RPC 实现服务的输出和输入功能Q可以和 Spring 框架无缝集成?/p>

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/alibaba/dubbo

5.  Hadoop

Hadoop 是一个分布式pȝ基础架构Q由Apache基金会开发。用户可以在不了解分布式底层l节的情况下Q开发分布式E序。充分利用集的威力高速运和存储?/p>

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://mirror.bit.edu.cn/apache/

6.  jQuery Mobile

jQuery MobileQjQueryMobileQ??nbsp;jQuery 在手Z和^板设备上的版本。jQuery Mobile 不仅会给LUdq_带来jQuery核心库,而且会发布一个完整统一的jQueryUdUI框架。支持全球主的Udq_?/p>

授权协议QMIT/GPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/jquery/jquery-mobile

7.  Nginx

NginxQ发韛_ engine xQ是一ƾ轻量的Web 服务器/反向代理服务器及?sh)子邮gQIMAP/POP3Q代理服务器。其特点是占有内存少Qƈ发能力强Q事实上nginx的ƈ发能力确实在同类型的|页伺服器中表现较好?/p>

授权协议QBSD
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://nginx.org/en/download.html

8.  Qt

Qt 是一个跨q_的C++囑Ş用户界面应用E序框架。它提供l应用程序开发者徏立艺术的图形用L面所需的所用功能。Qt是完全面向对象的Q很Ҏ(gu)扩展Qƈ且允许真正地lg~程?/p>

授权协议QGPL/LGPL/QPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://www.qt.io/download-open-source/

9.  

道是第一Ƒ֛产的开源项目管理YӞ她的核心理思想Z敏捷Ҏ(gu)scrumQ内|了产品理和项目管理,同时又根据国内研发现状补充了试理、计?理、发布管理、文档管理、事务管理等功能Q在一个Y件中可以将软g研发中的需求、Q务、bug、用例、计划、发布等要素有序的跟t管理v来,完整地覆 盖了目理的核心流E?/p>

授权协议QLGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://git.oschina.net/wwccss/zentaopms

10.  Redmine

Redmine 是一个开源的、基于Web的项目管理和~陷跟踪工具。它用日历和甘特图辅助项目及q度可视化显C。同时它又支持多目理。Redmine是一个自由开?源码软g解决Ҏ(gu)Q它提供集成的项目管理功能,问题跟踪Qƈ为多个版本控刉项的支持?/p>

授权协议QGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/redmine/redmine

11.  CKEditor

CKEditor 是新一代的 FCKeditorQ是一个重新开发的版本。CKEditor是全球最优秀的网在U文字编辑器之一Q因其惊人的性能与可扩展性而广泛的被运用于各大|站?/p>

授权协议QGPL/LGPL/MPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://ckeditor.com/download

12.  TeamTalk

TeamTalk 是由蘑菇街开发的开源即旉讯解决Ҏ(gu)Q适用于中型企业Q提供可靠的消息传递机Ӟ支持文字、图片、语音等富文本信息;文g收发{?/p>

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/mogutt

13.  Afinal

Afinal 是一?Android ?Sqlite ORM ?IOC 框架。同时封装了Android 中的 HTTP 框架Q其更加简单易用。Afinal 的宗旨是z,快速。约定大于配|的方式。尽量一行代码完成所有事情?/p>

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://git.oschina.net/fuhai/afinal

14.  ECharts

ECharts 开源来自百度商业前端数据可视化团队Q基于html5 CanvasQ是一个纯Javascript图表库,提供直观Q生动,可交互,可个性化定制的数据可视化图表。创新的拖拽重计、数据视图、值域漫游{特 性大大增Z用户体验Q赋予了用户Ҏ(gu)据进行挖掘、整合的能力?/p>

授权协议QBSD
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/ecomfe/echarts

15.  Semantic UI

Semantic UI — 完全语义化的前端界面开发框Ӟ?nbsp; Bootstrap ?nbsp; Foundation 比v来,q是有些不同的,在功能特性上、布局设计上、用户体验上均存在很多差异?/p>

授权协议QMIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/Semantic-Org/Semantic-UI

16.  SWFUpload

SWFUpload 是一个客L文g上传工具Q最初由Vinterwebb.se开发,它通过整合Flash与JavaScript技术ؓWEB开发者提供了一个具有丰富功能而超传l?<input type="file"/> 标签的文件上传模式?/p>

授权协议QMIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/WordPress/secure-swfupload

17.  GoAgent

GoAgent 是一个用Python和Google Appengine SDK~写的代理YӞgoagent的初h弥补gappproxy的不?/p>

授权协议QGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://git.oschina.net/goagent/goagent

18.  Android Studio

Android Studio 是一个全新的 Android 开发环境,Z IntelliJ IDEA. cM Eclipse ADTQAndroid Studio 提供了集成的 Android 开发工L于开发和调试?/p>

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://developer.android.com/sdk/index.html

19.  Druid

Druid 是一个JDBClgQ它包括三部分:DruidDriver 代理DriverQ能够提供基于FilterQChain模式的插件体p;DruidDataSource 高效可管理的数据库连接池QSQLParser?br />

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://git.oschina.net/wenshao/druid

20.  Nagios

Nagios是一个监视系l运行状态和|络信息的监视系l。Nagios能监视所指定的本地或q程L以及服务Q同时提供异帔R知功能{?/p>

授权协议QGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://www.nagios.org/download/

21.  Amaze UI

Amaze UI 是中国首个开?HTML5 跨屏前端框架。Amaze UI 是一个轻量、Mobile first的前端框Ӟ Z开源社区流行前端框架编写?/p>

授权协议QMIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://git.oschina.net/amazeui/amazeui

22.  Docker

Docker 是一个开源的应用容器引擎Q让开发者可以打包他们的应用以及依赖包到一个可UL的容器中Q然后发布到M行?Linux 机器上,也可以实现虚拟化?/p>

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/docker/docker

23.  fastjson

fastjson 是一个性能很好?Java 语言实现?JSON 解析器和生成器,来自阉K巴巴的工E师开发?/p>

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://git.oschina.net/wenshao/fastjson

24. CrossApp

CrossApp是一Ƒ֮全开源、免贏V跨q_的移动应用开发引?。CrossApp 采用 C++ 开发(卛_支持 JS ?Lua ~写Q,可直接导?iOS ?Android 原生应用Q拥有高性能Q多控gQ开发速度快的优势?/p>

授权协议QMIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://git.oschina.net/9miao/CrossApp

25. Sonar

Sonar (SonarQube)是一个开源^収ͼ用于理源代码的质量。Sonar 不只是一个质量数据报告工P更是代码质量理q_。支持的语言包括QJava、PHP、C#、C、Cobol、PL/SQL、Flex {?/p>

授权协议QLGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/SonarSource/sonarqube

26. xUtils

xUtils 最初源?nbsp; Afinal 框架Q进行了大量重构Q?xUtils 支持大文件上传,更全面的 http h协议支持(10 U谓?Q拥有更加灵zȝ ORMQ更多的事g注解支持且不受؜淆媄?..

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/wyouflf/xUtils

27. TeamLab

TeamLab 是一个免费开源的商业协作和项目管理的q_。TeamLab 主要功能包括Q项目管理、里E碑理、Q务、报表、事件、博客、论坛、书{、Wiki、即时消息等{?/p>

授权协议QAGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://sourceforge.net/projects/teamlab/files/

28. memcached

memcached ?一套分布式的快取系l,当初是Danga InteractiveZLiveJournal所发展的,但目前被许多软gQ如MediaWikiQ所使用。memcachedh多种语言的客L 开发包Q包括:Perl/PHP/JAVA/C/Python/Ruby/C#/MySQL/?/p>

授权协议QBSD
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://code.google.com/p/memcached/downloads/list

29. Magnolia

Magnolia CMS 是一家瑞士公司自 2003 qv发布的一个基?nbsp;Java 的开源内容管理系l。它适合且已被用在以下领域Q?/span>?sh)子商?/span>、银?/span>、媒体娱?/span>?span style="font-size: 10pt; line-height: 1.5;">政府、旅游、航I?/span>、工业制造?/span>教育和保?/span>?/span>

授权协议QGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://git.magnolia-cms.com/gitweb/

30. Django

Django 目是一个定?Python WEB 框架Q它源自一个在U新?Web 站点Q于 2005 q以开源的形式被释攑և来?/p>

授权协议QBSD
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://www.djangoproject.com/download/

31. zabbix

zabbix是一个基于WEB界面的提供分布式pȝ监视以及|络监视功能的企业的开源解x案。zabbix能监视各U网l参敎ͼ保证服务器系l的安全q营Qƈ提供柔Y的通知机制以让pȝ理员快速定?解决存在的各U问题?/p>

授权协议QGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://www.zabbix.com/download.php

32. Kettle

Kettle是一Ƒ֛外开源的etl工具Q纯java~写Q绿色无需安装Q数据抽取高效稳?数据q移工具)。Kettle中有两种脚本文gQtransformation和jobQtransformation完成针对数据的基转换Qjob则完成整个工作流的控制?/p>

授权协议QLGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://sourceforge.net/projects/pentaho/files/Data%20Integration/

33. Node.js

Node.js 是一套用来编写高性能|络服务器的 JavaScript 工具包,一pd的变化由此开始。比较独特的是,Node.js 会假设你是在 POSIX 环境下运行它 Linux ?Mac OS X?/p>

授权协议QMIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://nodejs.org/download/

34. MyBatis

MyBatis 的前w就?nbsp;iBatis 。是一个数据持久层(ORM)框架。在UJavadocQ?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://tool.oschina.net/apidocs/apidoc?api=mybatis-3.1.1

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/mybatis/mybatis-3

35. TortoiseGit

TortoiseGit (龟Git)?a rel="nofollow" target="_blank" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">TortoiseSVN?a rel="nofollow" target="_blank" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">Git版本Qtortoisegit用于q移TortoiseSVN到TortoiseGitQ一直以来Git在Windowsq_没有好用GUI客户端,现在tortoisegit的出现给Windows开发者带来福韟?/p>

授权协议QGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://code.google.com/p/tortoisegit/

36. Openfire

Openfire 是实时的ZWEB的即时消息传输^収ͼ是原来的Jive Messenger?/p>

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://www.igniterealtime.org/downloads/index.jsp

37. ZUI

zui 是禅道项目管理Y件团队在完善自己产品q程中Ş成的一个开源前端实跉|案,帮助你快速构C跨屏应用。简单美观,易于使用Q快速构建简z大方的Cweb应用?/p>

授权协议QMIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://git.oschina.net/wwccss/zui

38. Cocos2d-x

Cocos2D-X 是全球知名的开源跨q_游戏引擎Q易学易用,目前已经支持iOS、Android、Windows桌面、Mac OSX、Linux、BlackBerry、Windows Phone{^台。Cocos2d-JSl一了用JSq行开发的开发体验,HTML5引擎与JSB的API高度l一h?/span>

授权协议QMIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://www.cocos2d-x.org/download?project_id=cocos2d-x

39. D3.js

D3 是最行的可视化库之一Q它被很多其他的表格插g所使用。它允许l定L数据到DOMQ然后将数据驱动转换应用到Document中。你可以使用它用一个数l创建基本的HTML表格Q或是利用它的流体过度和交互Q用怼的数据创建惊人的SVG条Ş图?/p>

授权协议QMIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/mbostock/d3

40. Twitter Storm

Twitter Storm 是一个分布式的、容错的实时计算pȝ。Storm 为分布式实时计算提供了一l通用原语Q可被用?#8220;处?#8221;之中Q实时处理消息ƈ更新数据库。这是管理队列及工作者集的另一U方式?/p>

授权协议QEPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/nathanmarz/storm

41. Redis

Redis 是一个高性能的key-value数据库?redis的出玎ͼ很大E度补偿?a rel="nofollow" target="_blank" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">memcachedq类keyvalue存储的不I在部 分场合可以对关系数据库v到很好的补充作用。它提供了PythonQRubyQErlangQPHP客户端,使用很方ѝ?/p>

授权协议QBSD
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/antirez/redis

42. Nutch

Nutch 是一个开源Java 实现的搜索引擎。它提供了我们运行自q搜烦引擎所需的全部工兗包括全文搜索和Web爬虫?/p>

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://www.apache.org/dyn/closer.cgi/nutch/

43. PhoneGap

PhoneGap 是一?HTML5 q_Q通过它,开发商可以使用 HTML、CSS ?JavaScript 来开发本地移动应用程序。因此,目前开发商可以只编写一ơ应用程序,然后?7 个主要的Udq_和应用程序商?(App Store) 里进行发布?/p>

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/phonegap/phonegap

44. Mono

Mono 是一个由 Novell 公司L的项目。该目的目标是创徏一pdW合ECMA 标准QEcma-334 和Ecma-335Q的.NET 工具Q包括C# ~译器和共通语a执行q_。与微Y?NET Framework 不同QMono 目不仅可以q行于Windows pȝ上,q可以运行于LinuxQFreeBSDQUnixQMac OS X 和Solaris?/p>

授权协议QGPL/LGPL/MIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://www.mono-project.com/

45. Seafile

Seafile 是新一代的开源云存储软g。它提供更丰富的文g同步和管理功能,以及更好的数据隐U保护和组协作功能。Seafile 支持 Mac、Linux、Windows 三个桌面q_Q支?Android ?iOS 两个Udq_?/p>

授权协议QGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://git.oschina.net/lins05/seafile

46. ElasticSearch

Elastic Search 是一个基?a rel="nofollow" target="_blank" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">Lucene构徏的开源,分布式,RESTful搜烦引擎。设计用于云计算中,能够辑ֈ实时搜烦Q稳定,可靠Q快速,安装使用方便。支持通过HTTP使用JSONq行数据索引?/p>

授权协议QApache
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/elasticsearch/elasticsearch

47. Tor

Tor 是一个帮助你抵M量分析的Y仉目, 量分析是一U对|络的监视行为。Tor 你的通信通过一个由遍及全球的志愿者运行的中QrelayQ所l成的分布式|络转发Q?以此来保护你的安全:它o监视你的 Internet q接的那些h无法知道你所讉K的站点, 它还令你所讉K的站Ҏ(gu)法知道你的物理位|?/p>

授权协议QBSD
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://www.torproject.org/

48. Cacti

Cacti 是一套基于PHP,MySQL,SNMP及RRDTool开发的|络量监测囑Ş分析工具。它通过snmpget来获取数据,使用 RRDtooll画囑ŞQ而且你完全可以不需要了解RRDtool复杂的参数?/p>

授权协议QGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://www.cacti.net/

49. GitLab

GitLab是一个利?nbsp;Ruby on Rails 开发的开源应用程序,实现一个自托管?a rel="nofollow" target="_blank" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">Git目仓库Q可通过Web界面q行讉K公开的或者私人项目。它拥有?a rel="nofollow" target="_blank" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">GithubcM的功能,能够览源代码,理~陷和注释?/p>

授权协议QMIT
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">https://github.com/gitlabhq/gitlabhq

50. Notepad++

Notepad++ 是一N常有特色的编辑器Q是开源YӞ可以免费使用。支持的语言: C, C++ , Java , C#, XML, HTML, PHP, JavascriptQ?/p>

授权协议QGPL
源码下蝲Q?a target="_blank" rel="nofollow" bluelink"="" tabindex="-1" style="border: 0px none; outline: none; color: #296bcc;">http://notepad-plus-plus.org/



paulwong 2015-01-07 00:08 发表评论
]]>
解压ZIP文ghttp://www.aygfsteel.com/paulwong/archive/2014/10/29/419179.htmlpaulwongpaulwongWed, 29 Oct 2014 09:34:00 GMThttp://www.aygfsteel.com/paulwong/archive/2014/10/29/419179.htmlhttp://www.aygfsteel.com/paulwong/comments/419179.htmlhttp://www.aygfsteel.com/paulwong/archive/2014/10/29/419179.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/419179.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/419179.html
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
</dependency>

ZipUtil.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ZipUtil {
    
    private static Logger logger = LoggerFactory.getLogger(ZipUtil.class);
    
    public static void extractFolder(InputStream inputStream, String outputFolder) throws IOException 
    {
        ZipInputStream zis = null;
        try {

            Charset GBK = Charset.forName("GBK");
            zis = new ZipInputStream(inputStream, GBK);
            ZipEntry entry;

            while ((entry = zis.getNextEntry()) != null) {

                // Create a file on HDD in the destinationPath directory
                
// destinationPath is a "root" folder, where you want to extract your ZIP file
                String encoding = System.getProperty("file.encoding");
                logger.info("encoding:"+encoding); 
                
                String fileName = new String(entry.getName().getBytes("GBK"), encoding);
                File entryFile = new File(outputFolder, fileName);
//                File entryFile = new File(outputFolder, entry.getName());
                if (entry.isDirectory()) {

                    if (entryFile.exists()) {
                        logger.warn("Directory {0} already exists!", entryFile);
                    } else {
                        entryFile.mkdirs();
                    }

                } else {

                    // Make sure all folders exists (they should, but the safer, the better ;-))
                    if (entryFile.getParentFile() != null && !entryFile.getParentFile().exists()) {
                        entryFile.getParentFile().mkdirs();
                    }

                    // Create file on disk
                    if (!entryFile.exists()) {
                        entryFile.createNewFile();
                    }

                    // and rewrite data from stream
                    OutputStream os = null;
                    try {
                        os = new FileOutputStream(entryFile);
                        IOUtils.copy(zis, os);
                    } finally {
//                        os.close();
                        IOUtils.closeQuietly(os);
                        zis.closeEntry();
                    }
                }
            }
        } finally {
            IOUtils.closeQuietly(zis);
        }
    }
    
    public static void main(String [] args) throws IOException
    {
        final String INPUT_ZIP_FILE = "D:TESTING-FILE/ZIP/INPUT/应用.zip";
        String OUTPUT_FOLDER = "D:/TESTING-FILE/ZIP/OUTPUT";
        
        OUTPUT_FOLDER += File.separator + UUID.randomUUID().toString();
        
        InputStream inputStream = new FileInputStream(new File(INPUT_ZIP_FILE));
        
        extractFolder(inputStream, OUTPUT_FOLDER);
        
        /*File file = new File(OUTPUT_FOLDER);
        FileUtil.deleteFolder(file);
*/
    }

}



paulwong 2014-10-29 17:34 发表评论
]]>
EXCEL转JAVA BEANhttp://www.aygfsteel.com/paulwong/archive/2014/10/29/419178.htmlpaulwongpaulwongWed, 29 Oct 2014 09:25:00 GMThttp://www.aygfsteel.com/paulwong/archive/2014/10/29/419178.htmlhttp://www.aygfsteel.com/paulwong/comments/419178.htmlhttp://www.aygfsteel.com/paulwong/archive/2014/10/29/419178.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/419178.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/419178.html
        <dependency>
            <groupId>net.sf.jxls</groupId>
            <artifactId>jxls-core</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sf.jxls</groupId>
            <artifactId>jxls-reader</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sf.jxls</groupId>
            <artifactId>jxls-examples</artifactId>
        </dependency>


转换的配|文Ӟ
<workbook>
  <worksheet name="Sheet1">
    <section startRow="0" endRow="0" />
    <loop startRow="1" endRow="1" items="result" var="app" varType="n.app.valueobject.App">
      <section startRow="1" endRow="1">
        <mapping row="1" col="0">app.title</mapping>
        <mapping row="1" col="1">app.categoryId</mapping>
        <mapping row="1" col="2">app.updateContent</mapping>
        <mapping row="1" col="3">app.rank</mapping>
        <mapping row="1" col="4">app.installedQty</mapping>
        <mapping row="1" col="5">app.installedType</mapping>
        <mapping row="1" col="6">app.discuss</mapping>
        <mapping row="1" col="7">app.summary</mapping>
        <mapping row="1" col="8">app.deviceTypes</mapping>
        <mapping row="1" col="9">app.description</mapping>
        <mapping row="1" col="10">app.newFeatures</mapping>
        <mapping row="1" col="11">app.shortRecommend</mapping>
        <mapping row="1" col="12">app.appUrl</mapping>
      </section>
      <loopbreakcondition>
        <rowcheck offset="0">
          <cellcheck offset="0" />
        </rowcheck>
      </loopbreakcondition>
    </loop>
  </worksheet>
</workbook>



JAVA代码Q?br />
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.jxls.reader.ReaderBuilder;
import net.sf.jxls.reader.XLSReader;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

import application.app.valueobject.App;

public class ExcelUtil<T> {
    
    private static Logger logger = LoggerFactory.getLogger(ExcelUtil.class);
    
    public List<T> parseExcelFileToBeans(InputStream xlsFileInputStream, InputStream jxlsConfigInputStream) throws IOException, SAXException, InvalidFormatException  {
        
        
        List<T> result = new ArrayList<T>();
        Map<String, Object> beans = new HashMap<String, Object>();
        beans.put("result", result);
        InputStream inputStream = null;
        try {
            XLSReader xlsReader = ReaderBuilder.buildFromXML(jxlsConfigInputStream);
            inputStream = new BufferedInputStream(xlsFileInputStream);
            xlsReader.read(inputStream, beans);
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
            throw e;
        } catch (SAXException e) {
            logger.error(e.getMessage(), e);
            throw e;
        } catch (InvalidFormatException e) {
            logger.error(e.getMessage(), e);
            throw e;
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (Exception e) {
                }
            }
        }
        return result;
    }
    
    public static void main(String[] args) throws Exception {
        
        String path = "D:/DATA/TESTING-FILE/EXCEL";
        
        path = System.getProperty("user.home");
        
        ExcelUtil<App> util = new ExcelUtil<App>();
        String excelFilePath = path + File.separator + "appData.xls";
        
        InputStream configInputStream = 
                ExcelUtil.class.getResourceAsStream("/excel/template/config/app_config.xml");
        InputStream xlsFileInputStream = new FileInputStream(excelFilePath);
        
        List<App> appList = util.parseExcelFileToBeans(xlsFileInputStream, configInputStream);

        for (App app : appList) {
            System.out.println(app.toString());
        }
        
        /*String [] args2 = {""};
        GroupingSample.main(args2);
*/

    }

}


http://www.yihaomen.com/article/java/530.htm

paulwong 2014-10-29 17:25 发表评论
]]>
JAVAU程池例?/title><link>http://www.aygfsteel.com/paulwong/archive/2014/09/09/417757.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Mon, 08 Sep 2014 23:31:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2014/09/09/417757.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/417757.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2014/09/09/417757.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/417757.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/417757.html</trackback:ping><description><![CDATA[     摘要: 用途及用法       |络h通常有两UŞ式:W一U,h不是很频J,而且每次q接后会保持相当一D|间来L据或者写数据Q最后断开Q如文g下蝲Q网l流媒体{。另一UŞ式是h频繁Q但是连接上以后?写很量的数据就断开q接。考虑到服务的q发问题Q如果每个请求来C后服务都为它启动一个线E,那么q对服务的资源可能会造成很大的浪费,特别是第二种情况。因为通常?..  <a href='http://www.aygfsteel.com/paulwong/archive/2014/09/09/417757.html'>阅读全文</a><img src ="http://www.aygfsteel.com/paulwong/aggbug/417757.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2014-09-09 07:31 <a href="http://www.aygfsteel.com/paulwong/archive/2014/09/09/417757.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">Դ</a>| <a href="http://" target="_blank">İ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">ƽȪ</a>| <a href="http://" target="_blank">쳤</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˶</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">¡</a>| <a href="http://" target="_blank">С</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̺</a>| <a href="http://" target="_blank">Ƶ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank">Ʊ</a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank">ӻ</a>| <a href="http://" target="_blank">ڻ</a>| <a href="http://" target="_blank">Դ</a>| <a href="http://" target="_blank">ʡ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ѯ</a>| <a href="http://" target="_blank">Ѩ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ѳ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ʡ</a>| <a href="http://" target="_blank">˳</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɳ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Т</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ͨ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>