写了如下工具类: public class SystemUtil { public static String getRandomNumberByNum(int num) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < num; i++) { long randomNum = Math.round(Math.floor(Mat
/** * 人民币转成大写 * * @param value * @return String */ public static String hangeToBig(double value) { char[] hunit = { '拾', '佰', '仟' }; // 段内位置表示 char[] vunit = { '万', '亿' }; // 段名表示 char[] digit = { '零'
/** * 对 Double 类型的数据进行四舍五入 * @author gaoqing * 2014-12-2 * @param initValue 初始值 * @param scaleNum 保留小数点的位数 * @param tClass 保留小数点位数后,返回的数据类型的 Class * @return t 四舍五入后的值 */ public static <T> T roundDoule
/** * 半角转全角 * @param input String. * @return 全角字符串. */ public static String ToSBC(String input) { char c[] = input.toCharArray(); for (int i = 0; i < c.length; i++) { if (c[i] == ' ') { c[i] = '\u3000
private void downFile(HttpServletResponse response, HttpServletRequest request, String location){ BufferedInputStream bis = null; try { File file = new File(location); if (file.exists()) { long p = 0L
问题:用插入排序算法对n个对象的数组进行升序排序。 插入排序算法描述:插入排序的基本思想是,在一个已经排好序的子数组中查找一个位置,在找到的位置中插入一个元素,元素插入后,子数组依然有序。算法步骤如下: (1)初始状态,子数组只包含数组的第一个元素,这样,子数组自然 public <T extends Comparable<T>> void sort(T[] a) { // TODO Auto-g
在页面上显示各种文档中的内容。在servlet中的逻辑 word: BufferedInputStream bis = null; URL url = null; HttpURLConnection httpUrl = null; // 建立链接 url = new URL(urlReal); httpUrl = (HttpURLConnection) url.openConnection();/
在编程中经常会用到将字符串数字转换成ASCII值,前一段时间遇到了这个问题,下面是解决问题的代码,希望能够帮助到有需要的猿友们 //测试demo public static void main(String[] args) { int a=91151561; for (byte b : String.valueOf(a).getBytes()) { char c=(char) (b + 48);
模拟页面提交一个form public void submittingForm() throws Exception { final WebClient webClient = new WebClient(); // Get the first page final HtmlPage page1 = webClient.getPage("http://some_url"); // Get the
public class AntiXSS { /** * 滤除content中的危险 HTML 代码, 主要是脚本代码, 滚动字幕代码以及脚本事件处理代码 * * @param content * 需要滤除的字符串 * @return 过滤的结果 */ public static String replaceHtmlCode(String content) { if (null == conten
public static void fileCopy( File in, File out ) throws IOException { FileChannel inChannel = new FileInputStream( in ).getChannel(); FileChannel outChannel = new FileOutputStream( out ).getChannel();
public class BubbleSort { public static void sortiere(int[] x) { boolean unsortiert=true; int temp; while (unsortiert){ unsortiert = false; for (int i=0; i < x.length-1; i++) if (x[i] > x[i+1]) { temp
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mail.MailSender; import org.springframework.mail.SimpleMailMessage; import org.springframework.stereotype.Serv
约瑟夫环是一个数学的应用问题:已知n个人(以编号1,2,3...n分别表示)围坐在一张圆桌周围。从编号为k的人开始报数,数到m的那个人出列;他的下一个人又从1开始报数,数到m的那个人又出列;依此规律重复下去,直到圆桌周围的人全部出列。 2B求解: private void myJosf(int teamLength, int baoshu) { int[] team = new int[teamL
1、字符串数组与字符串之间的转换 一个字符串可以变为一个字符 数组,同样,也可以把一个字符数组,变为一个字符串。 在String类中提供了以下操作方法: 将字符串变为字符数组: public char[] toCharArray() public String(char[] value) public String(char[] value,int offset,int count) public
public final static String filterSQLInjection(String s) { if (s == null || "".equals(s)) { return ""; } try { s = s.trim().replaceAll("</?[s,S][c,C][r,R][i,I][p,P][t,T]>?", "");//script s = s.trim().r
package com.*; public class RC4 { public static String decry_RC4(byte[] data, String key) { if (data == null || key == null) { return null; } return asString(RC4Base(data, key)); } public static Strin
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); try { String name = sdf.format(new Date()); String filePath = System.getProperty("user.dir") + "//" + name + ".sql"; // 系统执行器 Runtime rt
上传下载是很简单的功能,但是每次用的时候还是要查,这里整理一下 前台: <form action="xxoo.do" enctype="multipart/form-data" method="post"> <input type="file" name="file" /> <button type="submit" class="btn btn-primary"> 提交 </form> 主
如果通过代理进来,则透过防火墙获取真实IP地址 public class IPUtil { private static Logger logger = Logger.getLogger(IPUtil.class); /** * 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址; */ public final static String getIpAddress(HttpSe