/** * 桶式排序: * * 仅支持非负数排序! * * 桶式排序不再是基于比较的了,它和基数排序同属于分配类的排序, 这类排序的特点是事先要知道待排 序列的一些特征。 桶式排序事先要知道待排 * 序列在一个范围内,而且这个范围应该不是很大的。 比如知道待排序列在[0,M)内,那么可以分配M个桶,第I个桶记录I的出现情况, * 最后根据每个桶收到的位置信息把数据输出成有序的形式。 这里我们用两个
/** * 日期工具类 */ public final class DateUtils { /** * 英文简写(默认)如:2010-12-01 */ public static String FORMAT_SHORT = "yyyy-MM-dd"; /** * 英文全称 如:2010-12-01 23:15:06 */ public static String FORMAT_LONG = "yy
package wzs.seek; /** * 二分查找 * @author wWX154783 * */ public class Test_wzs002 { public static void main(String[] args) { int[] intArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int result = separateSearch
import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.DESedeKeySpec; import javax.crypto.spec.IvPa
需求:读入一个浮点数值,将其转化为中文金额的大写形式。如123.45,转化为:壹佰贰拾叁元肆角伍分。 以下是各种情况要完善: 1. 当金额为整数,只表示整数部分,省略小数部分,并添加“整”字。如123表示为:壹佰贰拾叁元整。 2.当金额中含有连续的0时,只需写一个“零”即可。如10005表示为:壹万零伍元整。3.10的表示形式。如120表示为:壹佰贰拾元整。而10则表示为:拾元整。 public
/** * 上传带图片的http请求 * * @param murl网址 * @param map * 参数对 主要不要包括图片 * @param path * 图片路径 也可以是其他格式 自行做 * @return * @throws Exception */ static public String post(String murl, HashMap<String, String> map,
public static void main(String[] args) throws IOException{ Image img = Toolkit.getDefaultToolkit().getImage("C:\\google.jpg"); BufferedImage bi_scale = toBufferedImage(img); ImageIO.write(bi_scale, "j
Date lastExcTime=new Date(); CommandResult result = mongoTemplate.getDb().command( new BasicDBObject("distinct", "homeLog").append("key", "userId").append( "query", new BasicDBObject("createTime", new
全排列处理接口 public interface PermutationProcessor<T> { void process(T[]array); } 全排列类 public final class FullPermutation { public static <T> void permutate(T a[], PermutationProcessor<T> processor) { perm
public class Test implements Runnable { public void run() { try { System.out.println("在run()方法中 - 这个线程会运行20秒"); Thread.sleep(20000); System.out.println("在run()方法中 - 继续运行"); } catch (InterruptedExcepti
public class MD5 { /* * 四个链接变量 */ private final int A=0x67452301; private final int B=0xefcdab89; private final int C=0x98badcfe; private final int D=0x10325476; /* * ABCD的临时变量 */ private int Atemp,Bt
public BufferedImage rotate90DX(BufferedImage bi) { int width = bi.getWidth(); int height = bi.getHeight(); BufferedImage biFlip = new BufferedImage(height, width, bi.getType()); for(int i=0; i<width;
当我们需要读取Jar包内的文件时,我们就不能使用 new File(filePath) 来读取了,因为根本无法指定这个filePath,如果说在开发时,还可以利用 this.getClass().getResource() 来获得文件路径,那么当打成Jar包是,路径就不存在了。 这是我们要读取文件,就需要用流的形式了,我们需要利用 this.getClass().getResourceAsStre
public String checkIpAddress(HttpServletRequest request) { String ip = request.getHeader("x-forwarded-for"); if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHead
/** * Creates the request "https://www.mycallaccount.com/ot/triggerID1.asp". * Customer didn't provide public API for this service. Used Fiddler2 to * grab data and emulate request through browser * *
public class NetworkCheck { /** * 网络是否可用 */ public static boolean isNetworkAvailable(Context context) { ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNE
Bitmap bitmapOrg = BitmapFactory.decodeResource(this.getContext().getResources(), R.drawable.moon); Matrix matrix = new Matrix(); matrix.postRotate(-40); Bitmap resizedBitmap = Bitmap.createBitmap(bit
1. 通过FileInputStream读取文件输入流 public void export(String excelPath, String fileName) throws Exception{ //将文件存到指定位置 //读取目标文件流,转换调用下载 File resultFile = new File(excelPath);
public class GradientDescent { public static void main(String[] args) { double x = 3; double y = pow(x);// loss函数 while ((y = pow(x)) > 0.01) { double d = div(x);//求偏导 x = x - 0.01 * d;//下降更新 System.o
println(System.getProperty("java.version")); System.out.println(System.getProperty("java.vendor")); System.out