This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.FileOutputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.io.OutputStream; | |
| import java.net.URL; | |
| public class SaveImageFromUrl { | |
| public static void main(String[] args) throws Exception { | |
| String imageUrl = "https://www.google.com/images/srpr/logo3w.png"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static int countChar(String str) { | |
| int abccount = 0; | |
| int numcount = 0; | |
| int spacecount = 0; | |
| int othercount = 0; | |
| char[] b = str.toCharArray(); | |
| for (int i = 0; i < b.length; i++) { | |
| if (b[i] >= 'a' && b[i] <= 'z' || b[i] >= 'A' && b[i] <= 'Z') { | |
| abccount++; | |
| } else if (b[i] >= '0' && b[i] <= '9') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UrlUtils { | |
| public static final String ALLOWED_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'()"; | |
| public static String encodeURIComponent(String input) { | |
| if(StringUtils.isEmpty(input)) { | |
| return input; | |
| } | |
| int l = input.length(); | |
| StringBuilder o = new StringBuilder(l * 3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function (root, factory) { | |
| //seajs module define | |
| define(function(require, exports, module) { | |
| var jQuery = require('jquery'); | |
| factory(jQuery); | |
| }); | |
| }(this, function ($) { | |
| //export module | |
| return $; | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 电话号码验证 | |
| jQuery.validator.addMethod("isTel", function(value, element) { | |
| var tel = /^\d{3,4}-?\d{7,9}$/; //电话号码格式010-12345678 | |
| return this.optional(element) || (tel.test(value)); | |
| }, "请正确填写您的电话号码"); | |
| // 联系电话(手机/电话皆可)验证 | |
| jQuery.validator.addMethod("isPhone", function(value,element) { | |
| var length = value.length; | |
| var mobile = /^(((13[0-9]{1})|(18[0-9]{1})|(15[0-9]{1}))+\d{8})$/; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| When we use JPA @oneToMany | |
| if you remove a dependent object from a OneToMany collection it will not be deleted, JPA1.0 don’t support it itself, it requires that you explicitly call remove() on it. | |
| In JPA2.0 ,you need do add “orphanRemoval” to “@OneToMany” , | |
| just like this: | |
| @OneToMany(mappedBy = "A", orphanRemoval=true,cascade = CascadeType.ALL) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| When we use JPA @oneToMany | |
| if you remove a dependent object from a OneToMany collection it will not be deleted, JPA1.0 don’t support it itself, it requires that you explicitly call remove() on it. | |
| In JPA2.0 ,you need do add “orphanRemoval” to “@OneToMany” , | |
| just like this: | |
| @OneToMany(mappedBy = "A", orphanRemoval=true,cascade = CascadeType.ALL) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 扩充String原型,字符串模板格式化 | |
| * <code> | |
| * Array数据: '{0}'.format('hello world') ; | |
| * json数据:'{name}'.format({'name':'hello world'}); | |
| * 输出结果:hello world | |
| * </code> | |
| * @author Gongle | |
| * @date 2013年4月22日10:50:29 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <iframe src="javascript:;" width="750" height="30" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| 日期格式字符串转为Date.getTime对象 | |
| @param str 日期格式字符串 | |
| @return Date time | |
| <p> | |
| eg: string2Date(2013-07-13 10:00:00' ) -> 1373700600000 | |
| </p> | |
| **/ | |
| function string2Date(str){ | |
| return (new Date(Date.parse(str.replace(/-/g, "/")))).getTime() ; |
NewerOlder