2012年12月25日

java常用算法

摘要: 插入排序:packageorg.rut.util.algorithm.support;importorg.rut.util.algorithm.SortUtil;publicclassInsertSort implements SortUtil.Sort{/* (non-Javadoc) * @see org.rut.util.algorithm.SortUtil.Sort#sort(int[]) */publicvoidsort(int[] data) {inttemp;for(inti=1;i<data.length;i++){for(intj=i;(j>0)&& 阅读全文

posted @ 2012-12-25 18:06 Code changes life 阅读(12156) 评论(1) 推荐(1) 编辑

java根据头文件获取文件类型

摘要: /** * 件头是位于文件开头的一段承担一定任务的数据,一般都在开头的部分。 * 头文件作为一种包含功能函数、数据接口声明的载体文件,用于保存程序的声明(declaration),而定义文件用于保存程序的实现 (implementation)。 * 为了解决在用户上传文件的时候在服务器端判断文件类型的问题,故用获取文件头的方式,直接读取文件的前几个字节,来判断上传文件是否符合格式。具体代码如下: * Java代码 : * */package com.yonyou.sud.file;import java.io.FileInputStream;import java.io.IOExcepti.. 阅读全文

posted @ 2012-12-25 17:28 Code changes life 阅读(10924) 评论(1) 推荐(0) 编辑

java取小数点后两位

摘要: package com.yonyou.sud.algorithm;import java.math.BigDecimal;import java.text.DecimalFormat;/** * java取小数点后两位小数 * @author Sud * */public class Decimal62 { public static void main(String[] args) { /* * 第一种方法 java.text.DecimalFormat */ DecimalFormat df = new DecimalFormat("#.##"); double d = 阅读全文

posted @ 2012-12-25 15:39 Code changes life 阅读(30886) 评论(0) 推荐(0) 编辑

导航