归并排序的时间复杂度是:nlogn主要是用到二路归并排序,也就是把两个有序集合合并为一个有序集合.下面是我写的一个递归二路归并排序的算法:package algorithm;public class MergeSort { // private static long sum = 0; /** * <pre> * 二路归并 ……继续阅读 » 水墨上仙 5年前 (2021-04-07) 3091浏览 771个赞
使用对象.属性来自定义要生成的excel内容import java.io.ByteArrayInputStream;import java.io.ByteArrayOutputStream;import java.io.InputStream;import java.io.UnsupportedEncodingException;import ……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1973浏览 2721个赞
java实现产生固定时间段里面的随机日期public class test{ public static void main(String[] args) { Date randomDate = randomDate("2012-06-01", "2012-12-12&……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2349浏览 1960个赞
用javaCC实现double型数据的加减乘除法,正弦、余弦、正切、余切、反正弦、反余弦、反正切、反余/** * JavaCC file */ options { JDK_VERSION = "1.5";}PARSER_BEGIN(computer)package com.zju.edu;import java.……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2146浏览 1259个赞
java批量将gbk的乱码文件转换到utf8package com.iteye.niewj.util;import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import j……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2653浏览 1924个赞
Java 遍历Map的同时时删除指定元素package net.nie.test;import java.util.HashMap;import java.util.Iterator;import java.util.Map;public class HashMapTest { private static Map<Integer……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2130浏览 2744个赞
下文代码中,除了指定rootlogger输出到控制台和文件logdemo.log中之外,还定义了一个指定目的的子logger,令其日志输出到logdemo2.log文件中,同时它不继承rootlogger的输出特性。来源:http://blog.csdn.net/dongzi87/article/details/8292865 ……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1488浏览 2785个赞
子线程循环10次,接着主线程循环100次,接着回到子线程循环10次,接着再回到主线程循环100次,如此循环50次package com.jb.liang;public class TraditionalThread3 { /** * 互斥,上锁都是放在待操作的资源的类的内部方法中,而不是线程代码中 * @author jiall * 子……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2465浏览 1556个赞
java PDF文件解析成Stringboolean sort = false;// 是否排序int startPage = 1;// 开始提取页数int endPage = Integer.MAX_VALUE;// 结束提取页数Writer output = null;// 文件输入流,生成文本文件PDDocument document = ……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2905浏览 1815个赞
java非递归检索文件夹下所有文件DateFormat df = DateFormat.getDateTimeInstance();LinkedList<File> folders = new LinkedList<File>();LinkedList<File> filelists = new LinkedLi……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2846浏览 536个赞
Java对json是否合法进行格式校验/** * 用于校验一个字符串是否是合法的JSON格式 * */import java.text.CharacterIterator;import java.text.StringCharacterIterator;public class JsonValidator { private Ch……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1517浏览 641个赞
java对properties文件进行解析,在用java自带的properties类进行properties文件解析的时候,输出的时候很可能出现乱码问题,在开始的时候我也是找不到问题,查出了之后,贴出来跟大家分享。作者:xulong1516519package properties;import java.io.File;import java.i……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2805浏览 675个赞
Java DOC 转换给 PDF 格式文档import java.io.File;import java.net.ConnectException;import java.util.Date;import com.artofsolving.jodconverter.DocumentConverter;import com.artofsolvin……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1950浏览 1195个赞
可以用于有向图和无向图。用负数表示该有向路不通。在EditPlus上写的,所以就一个.java文件。package Test;import java.util.TreeMap;import java.util.ArrayList;import java.io.BufferedReader;import java.io.InputStreamRe……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1718浏览 1902个赞
Java读写二进制文件import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; impor……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2363浏览 1676个赞
Java查找目录下的及子目录下的指定扩展名的文件package FileDemo;import java.io.BufferedWriter;import java.io.File;import java.io.FileWriter;import java.io.FilenameFilter;import java.io.IOExceptio……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1706浏览 1422个赞
java操作XML中的占位符 有时XML的某些内容是待定的,对于这些内容可以在XML文件中使用占位符<people> <person id="001"> <name>$name</name> ……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2871浏览 2551个赞
java在web端直接输出Excel实现下载public String excelDomnload() throws Exception{ try{ /* String path = GlobalKeys.getFunctionConfig("user_attach_save","/opt/tmp/&qu……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2778浏览 462个赞
Java实现的字符型进度条package com.gondi.util;/** * 显示进度条(参数:当前点、结束点、进度条长度) * example: * System.out.println(ProgressBar.showBarByPoint(30, 100, 20)); * result: * [-----> ……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2446浏览 1600个赞
Java读取Html文本解析email地址的代码代码来自:http://blog.csdn.net/javaalpha/article/details/8332587package com.alpha.test;import java.io.BufferedReader;import java.io.File;import java.io.File……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2798浏览 1220个赞
Java获取系统当前时间的方法并指定格式/** * 返回当前日期时间字符串<br> * 默认格式:yyyy-mm-dd hh:mm:ss * * @return String 返回当前字符串型日期时间 */ public static String getCurrentTime() { String return……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2205浏览 1388个赞
创建ZIP和JAR文件import java.util.zip.*;import java.io.*;public class ZipIt {public static void main(String args[]) throws IOException {if (args.length < 2) {System.err.prin……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1813浏览 2441个赞
java发送邮件import javax.mail.*;import javax.mail.internet.*;import java.util.*;public void postMail( String recipients[ ], String subject, String message , String from) throws……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2048浏览 1141个赞
发送代数据的HTTP 请求import java.io.BufferedReader;import java.io.InputStreamReader;import java.net.URL;public class Main {public static void main(String[] args) {try {URL my_ur……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2966浏览 831个赞
把 Array 转换成 Mapimport java.util.Map;import org.apache.commons.lang.ArrayUtils;public class Main {public static void main(String[] args) {String[ ][ ] countries = { { &quo……继续阅读 » 水墨上仙 5年前 (2021-04-07) 3109浏览 1207个赞
Java正则表达式提取 Email 地址import java.util.regex.Matcher;import java.util.regex.Pattern;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.io……继续阅读 » 水墨上仙 5年前 (2021-04-07) 3080浏览 755个赞
Java中,通常有两种遍历HashMap的方法,大家可以参考一下:转自:http://blog.csdn.net/newcnzz/article/details/8434631import java.util.*; public class MapTest { static HashMap<String, Integer> ……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2485浏览 1209个赞
Java中创建与启动线程(Threading)的代码演示转自:http://java.chinaitlab.com/line/373702.htmlpublic class MyThread_1 extends Thread{public void run(){//some code }} ……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2892浏览 2945个赞
Java实现简单的鼠标划线import javax.swing.JFrame;import javax.swing.JPanel;import java.awt.Graphics;import java.awt.event.MouseListener;import java.awt.event.MouseMotionListener;impo……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1400浏览 1125个赞
java实现的二分查找法static public int search(int [] array, int target){ int high = array.length, low = -1, probe; while (high - low > 1) { probe = (low + high) &……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2924浏览 1080个赞
java代码将时间从sourceTZ时区转换成targetTZ时区/* * Converts time from sourceTZ TimeZone to destTZ TimeZone. * * @return converted time, or the original time, in case the datetime c……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1683浏览 2564个赞
Java运行时获得参数类型class A<T> { Class<T> specializedClass; public A() { this.specializedClass = (Class<T>) ((ParameterizedType) this.getClass() ……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2219浏览 1576个赞
Java创建二叉树并遍历的代码来源:http://blog.csdn.net/yhhazr/article/details/7944089public class BinaryTree { private Node root; /** * * 内部节点类 * @author yhh */ private class Node……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2411浏览 1868个赞
解析class的工具类package com.google.reflect;import java.lang.reflect.Field;import java.lang.reflect.Method;import java.lang.reflect.Modifier;import java.lang.reflect.Proxy;impo……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2495浏览 388个赞
java 文件夹操作import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.ni……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2071浏览 1348个赞
java生成pdf package com.hundsun.gildata.irp.core.action;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import com.hundsun.gildata.irp.common.……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1278浏览 2555个赞
Java模拟队列的出队和进队 package com.stackANDqueue;import java.io.DataInputStream;import java.io.IOException;/* * 循环队列的入队和出队 */public class Queue { static int MAX = 20; static ……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1452浏览 1297个赞
—–初试阿里云平台——目录—–初试阿里云平台——一、什么是阿里云平台与阿里云Serverless技术二、日常部署三、个人心得一、什么是阿里云平台与阿里云Serverless技术云开发平台是面向开发者打造的一站式、全云端的开发平台,打开浏览器就可以开发、调试、上线,……继续阅读 » Thomas_one 5年前 (2021-04-07) 2633浏览 0评论324个赞
JS代码时间格式与时间戳的相互转换 一.时间转换时间戳function transdate(endTime){var date=new Date();date.setFullYear(endTime.substring(0,4));date.setMonth(endTime……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1488浏览 349个赞
JavaScript添加到收藏夹和设置为主页的代码,网站上经常用到的两个功能// JavaScript Document// 加入收藏 < a onclick="AddFavorite(window.location,document.title)" >加入收藏< /a>function AddFav……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1782浏览 1117个赞
JavaScript SHA512加密算法详细代码/* * A JavaScript implementation of the Secure Hash Algorithm, SHA-512, as defined * in FIPS 180-2 * Version 2.2 Copyright Anonymous Contributor, Pau……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2194浏览 2576个赞
JavaScript SHA-256加密算法详细代码/* * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined * in FIPS 180-2 * Version 2.2 Copyright Angel Marin, Paul Johnsto……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2507浏览 2506个赞
JavaScript SHA1加密算法实现详细代码/* * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined * in FIPS 180-1 * Version 2.2 Copyright Paul Johnston 2000 - 2009. ……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1821浏览 2949个赞
当鼠标在图片上方时,图片停止漂浮,点击关闭按钮可隐藏图片,代码简单,直接插入网页更换成自己的漂浮图片就可以使用。<body><div id="float" style=" position:absolute; z-index:3"><img id="img1"……继续阅读 » 水墨上仙 5年前 (2021-04-07) 2329浏览 291个赞
JavaScript检测浏览器cookie是否已经启动,代码稍显复杂,通过写入一个测试cookie判断cookie是否已经启动var dt = new Date(); dt.setSeconds(dt.getSeconds() + 60); document.cookie = "cookietest=1; expires=" +……继续阅读 » 水墨上仙 5年前 (2021-04-07) 1624浏览 1639个赞