`
chenliang1234576
  • 浏览: 195068 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Java数据类型转换已经字符串处理工具类

    博客分类:
  • Java
阅读更多
package com.project.system.util;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import java.util.Vector;
 
/**** 
 * {@docRoot    所有的数据转换处理 }
 * @version     1.0
 * @since       2011\4\13
 * ****/
public class DataTypeChange {
/***
 * 表 Java中的简单类型 

简单类型 boolean byte char     short  int     long float double void 
二进制位数 1      8    16        16    32      64   32    64     -- 
字节数     1      1     2        2     4       8    4      8     0
C++范围    1      1     1        2     4       4    4      8     0                            
封装器类 Boolean Byte Character Short Integer Long Float Double Void   
这里的java和c++中的char类型的大小是不同的
 * ***/ 
	// 将字符串转换成一定长度的字节数组
    /***
     * @param  src 需要输入处理的源字符串
     * @param  byte_len 固定大小
     * @return byte[]
     *    String --> byte[]
     * **/
    public  static  byte[] string2Bytes(String src,int byte_len){
  		byte[] b1 = new byte[byte_len];
			StringBuffer tempb = new StringBuffer();     // 临时填充数据
			int temp_len = 0;                            // 临时字符的大 
			int src_len = src.length();                  // 需要转换的字符串的长度
			char zero = '\0';
			if(src_len<byte_len){
				temp_len = byte_len - src_len;           // 计算填充位的大小
				for(int i=0;i<temp_len;i++){             // 循环填充占位符
					tempb.append(zero);
				} 
				b1 = (src+tempb.toString()).getBytes(); 
		//		tempb.delete(0, temp_len);               // 清空临时字符
			}else{                                       // 如果大于此规定的长度,则直接转为btye类型
				b1 = src.getBytes();
			}  
			return b1;
    }
   // 将字符串转换成一定长度的字符串,不足的添加'\0'标识
    /***
     * @param  src 需要输入处理的源字符串
     * @param  byte_len 固定大小
     * @return String 返回的长度为byte_len的字符串
     * 
     *  String --> fillString
     * **/
    public  static  String  fillString(String src,int byte_len){ 
  	        String fill_str = "";
			StringBuffer tempb = new StringBuffer();  // 临时填充数据
			int temp_len = 0;                         // 临时字符的大 
			int src_len = src.length();               // 需要转换的字符串的长度
			char zero = '\0';
			if(src_len<byte_len){
				temp_len = byte_len - src_len;        // 计算填充位的大小
				for(int i=0;i<temp_len;i++){          // 循环填充占位符
					tempb.append(zero);
				}
				fill_str = src+tempb.toString();
			} else{
				fill_str = src;
			}
			return  fill_str;
    } 
	//   byte[] --> int
	public  static int bytes2Int1(byte[] bytes) {
	         int num = bytes[0] & 0xFF;
		      num |= ((bytes[1] << 8) & 0xFF00);
	        return num; 
	}
	//   byte[] --> int
	public static int bytes2Int2(byte[] intByte) { 
		int fromByte = 0;  
	    for (int i = 0; i < 2; i++)
         {
         int n = (intByte[i] < 0 ? (int)intByte[i] + 256 : (int)intByte[i]) << (8 * i);
           System.out.println(n);
          fromByte += n;
         }
          return fromByte;
    } 
	// bytes to int
	public  static int bytesToInt(byte[] bytes) {
        int addr = bytes[0] & 0xFF;
        addr |= ((bytes[1] << 8) & 0xFF00);
        addr |= ((bytes[2] << 16) & 0xFF0000);
        addr |= ((bytes[3] << 24) & 0xFF000000);
        return addr;
    }

	// byte[] --> String
	public static String bytes2String(byte b[]){
		String result_str = new String(b);
		return result_str;
	}
	//  int --> byte[]
	public static byte[] int2Bytes(int res) {
		byte[] targets = new byte[4]; 
		targets[0] = (byte) (res & 0xff);// 最低位 
		targets[1] = (byte) ((res >> 8) & 0xff);// 次低位 
		targets[2] = (byte) ((res >> 16) & 0xff);// 次高位 
		targets[3] = (byte) (res >>> 24);// 最高位,无符号右移。 
		return targets; 
	} 
	// char --> byte[]
	public static byte[] char2Bytes(char ch){
       int temp=(int)ch;
	   byte[] b=new byte[2];
	   for (int i=b.length-1;i>-1;i--){
	      b[i] = new Integer(temp&0xff).byteValue();//将最高位保存在最低位
	      temp = temp >> 8;         //向右移8位
	     }
        return b;
	}	
	// char --> int 8-->16
	public static int char2Int(char c){
		return  c;
	}
	// int --> char 16-->8需要强制转换
	public static char int2Char(int i){
		return  (char)i;
	} 
	  /***
	   * 数据之间的转换操作
	   ***/
	// 数据大于10000的时候进行处理
	public static String getF10000(float f1){
		   String str = "";
		   double d1 = 0.0d;
		   if(f1>10000.0f&&f1<100000000.0d){// 数据在10万到1亿之间的数据
			   d1 = f1/10000.0f;
			   str = DataTypeChange.save2bit(d1)+"万";
		   }else if(f1>100000000.0d){
			   d1 = (double)f1/100000000.0d;
			   str = DataTypeChange.save2bit(d1)+"亿";
		   }else{ 
			   d1 = f1;
			   str = DataTypeChange.save2bit(d1)+"";
		   }
		   return str;
	   } 
	// 截取byte数组从start到end的位置转换成strng
	 /***
	  * @input   src         待截取字节数组
	  *          start       待截取字节数组的开始位置
	  *          src_size    截取的长度 == 数据类型的长度
	  *           
	  * @output  int 字节截取转换成int后的结果
	  * 
	  * **/
	public static int bytesSub2Int(byte[] src,int start,int src_size) { 
		//if(src.length==0){
			byte[] resBytes = new byte[src_size];
	    	System.arraycopy(src, start, resBytes, 0, src_size);  
		    return  bytesToInt(resBytes);
//		}else{
//			return 0;
//		} 
	}
	
	 /***
	  * @input   src         待截取字节数组
	  *          start       待截取字节数组的开始位置
	  *          src_size    截取的长度 == 数据类型的长度
	  *           
	  * @output  String 字节截取转换成String后的结果
	  * 
	  * **/
	public static String bytesSub2String(byte[] src,int start,int src_size) { 
		byte[] resBytes = new byte[src_size];
		System.arraycopy(src, start, resBytes, 0, src_size); 
	 // 	System.out.println(" len ==" +resBytes.length 
	 //		         + " sub_bytes = " + bytes2Int1(resBytes)); 
		return  bytes2String(resBytes);
	} 
	 /***
	  * @input   src         待截取字节数组
	  *          start       待截取字节数组的开始位置
	  *          src_size    截取的长度 == 数据类型的长度
	  *           
	  * @output  从start下标开始长度为src_size长度的字节数组结果
	  * 
	  * **/
	public static byte[] bytesSub(byte[] src,int start,int src_size) { 
		byte[] resBytes = new byte[src_size];
		System.arraycopy(src, start, resBytes, 0, src_size);  
		return  resBytes;
	}
	
	/**
	 * splite the src with sep, and place them in a array
	 * 
	 * @param src
	 * @param sep
	 * @return
	 */
	public static String[] splite(String src, String sep) {
		Vector v = new Vector();
		int index;
		int fromIndex = 0;
		while ((index = src.indexOf(sep, fromIndex)) != -1) {
			v.addElement(src.substring(fromIndex, index));
			fromIndex = index + sep.length();
		}
		v.addElement(src.substring(fromIndex, src.length()));
		String[] result = new String[v.size()];
		for (int i = 0; i < result.length; i++) {
			result[i] = (String) v.elementAt(i);
		}
		return result;
	}

	/**
	 * splite the src with sep, place them in a array, and replace sep with
	 * sep_code
	 * 
	 * @param src
	 * @param sep
	 * @param sep_code
	 * @return
	 */
	public static String[] splite(String src, String sep, String sep_code) {
		String[] result = splite(src, sep);
		replace(result, sep_code, sep);
		return result;
	}

	/**
	 * replace the child string with the newStr in the src
	 * 
	 * @param src
	 * @param oldStr
	 * @param newStr
	 * @return
	 */
	public static String replace(String src, String oldStr, String newStr) {
		int oldSize = oldStr.length();
		int newSize = newStr.length();
		int margin = newSize - oldSize;
		int offset = 0;
		StringBuffer sb = new StringBuffer(src);
		int index;
		int fromIndex = 0;
		while ((index = src.indexOf(oldStr, fromIndex)) != -1) {
			fromIndex = index + oldSize;
			sb.delete(index + offset, fromIndex + offset);
			sb.insert(index + offset, newStr);
			offset += margin;
		}
		return sb.toString();
	}

	/**
	 * replace the child string with the newStr in the String of the array
	 * 
	 * @param src
	 * @param oldStr
	 * @param newStr
	 */
	public static void replace(String[] src, String oldStr, String newStr) {
		for (int i = 0; i < src.length; i++) {
			src[i] = replace(src[i], oldStr, newStr);
		}
	}

	/**
	 * 
	 * @param para
	 *            the parameter name
	 * @param src
	 *            the text
	 * @return 
	 *           the value of the parameter
	 */
	public static String getParaVal(String para, String src) {
		String paraval = null;
		String tempPara = para;
		int s1 = 0;
		int s2 = 0;
		int len = 0;
		int httplen = 0;

		if (tempPara == null || src == null)
			return "";
		tempPara = tempPara + "=";
		len = tempPara.length();
		httplen = src.length();
		if (httplen == 0)
			return "";
		if (len == 0)// || len > 9)
			return "";

		s1 = src.indexOf(tempPara); // find the parameter name
		if (s1 == -1)
			return "";
		s2 = src.indexOf('&', s1);// find next &
		if (s2 == -1) {
			// the last one parameter
			paraval = src.substring(s1 + len);

		} else {
			paraval = src.substring(s1 + len, s2);
		}

		return paraval;
	}
	
	/**
	 * 
	 * @param para
	 *            the parameter name
	 * @param src
	 *            the text
	 * @param sep
	 *            the separator           
	 * @return 
	 *           the value of the parameter
	 */
	public static String getParaValEx(String para, String src, char sep) {
		String paraval = null;
		String tempPara = para;
		int s1 = 0;
		int s2 = 0;
		int len = 0;
		int httplen = 0;

		if (tempPara == null || src == null)
			return "";
		tempPara = tempPara + "=";
		len = tempPara.length();
		httplen = src.length();
		if (httplen == 0)
			return "";
		if (len == 0)// || len > 9)
			return "";

		s1 = src.indexOf(tempPara); //find the parameter name
		if (s1 == -1)
			return "";
		s2 = src.indexOf(sep, s1);// find next &
		if (s2 == -1) {
			// the last one parameter
			paraval = src.substring(s1 + len);

		} else {
			paraval = src.substring(s1 + len, s2);
		}

		return paraval;
	}

	//byte[]转float
	  /**
   * byte[] to float
   * @param b
   * @param index
   * @return float
   */
  public static float getFloat(byte[] b,int index)  throws Exception{   
      int i = 0;   
      i = ((((b[index + 3]&0xff)<<8 | (b[index + 2]&0xff))<<8) | (b[index + 1]&0xff))<<8 | (b[index + 0]&0xff);   
      return Float.intBitsToFloat(i);   
  }
 // byte[] --> float
  public static float bytes2Float(byte[] b){
  	float f = 0f;
  	try {
			  f = getFloat(b,0);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
  	return f; 
  } 
//bytes to int
	public  static short bytesToShort(byte[] bytes) {
      int addr = bytes[0] & 0xFF;
      addr |= ((bytes[1] << 8) & 0xFF00); 
      return (short)addr;
  }
  /*********** 保留有效数字的小数点后位数设置 start ************/	
  // 保留2位有效数字
  public static double save2bit(double t1){
	  double result = (double) (int) ((t1 + 0.005) * 100.0) / 100.0; 
	  return result;
  } 
  // 保留1位有效数字
  public static double save1bit(double t1){
	  double result = (double) (int) ((t1 + 0.005) * 10.0) / 10.0; 
	  return result;
  }
  /*********** 保留有效数字的小数点后位数设置 end     ************/ 
  /*********** 日期类型格式转换以及时差参数处理 start ************/
  // Long类型的毫秒转为日期字符
  public static String getStrDate(long time){
		 String str = "";
		 Date date = new Date(time);
		 TimeZone china=TimeZone.getTimeZone("GMT+08:00"); //时区设置
	     Calendar calendar = Calendar.getInstance(china);
	     calendar.setTime(date);
	     String mon = String.valueOf(calendar.get(Calendar.MONTH)+1); 
	     if(mon.length()==1){
	    	 mon = "0"+mon;
	     }
	     String day = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)); 
	     if(day.length()==1){
	    	 day = "0"+day;
	     } 
	     str = String.valueOf(calendar.get(Calendar.YEAR))
	          + mon
	          + day;
	    return str;
  } 
  // k线左侧显示的时间格式  月份天数小时分钟
  public static String getStrDTime(long time){
		 String str = "";
		 Date date = new Date(time);
		 TimeZone china=TimeZone.getTimeZone("GMT+08:00"); //时区设置
	     Calendar calendar = Calendar.getInstance(china);
	     calendar.setTime(date);
	     String mon = String.valueOf(calendar.get(Calendar.MONTH)+1); 
	     if(mon.length()==1){
	    	 mon = "0"+mon;
	     }
	     String day = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)); 
	     if(day.length()==1){
	    	 day = "0"+day;
	     } 
	     String hour = String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)); 
	     if(hour.length()==1){
	    	 hour = "0"+hour;
	     }
	     String minute = String.valueOf(calendar.get(Calendar.MINUTE)); 
	     if(minute.length()==1){
	    	 minute = "0"+minute;
	     }
	     str = mon + day + hour + minute;
	    return str;
} 
  // 获取当天是星期几
  public static int getNowMinute(long time){
	     int week = 1;
	     Date date = new Date(time); 
	     Calendar calendar = Calendar.getInstance();
	     calendar.setTime(date);
	     week = calendar.get(Calendar.MINUTE);
	     return week;
  }
  // 获取当天是星期几
  public static int getNowWeek(long time){
	     int week = 1;
	     Date date = new Date(time); 
	     Calendar calendar = Calendar.getInstance();
	     calendar.setTime(date);
	     week = calendar.get(Calendar.DAY_OF_WEEK);
	     return week;
  }
  // 获取当天几点
  public static int getNowHour(long time){
	     int week = 1;
	     Date date = new Date(time); 
	     Calendar calendar = Calendar.getInstance();
	     calendar.setTime(date);
	     week = calendar.get(Calendar.HOUR_OF_DAY);
	     return week;
  }
  // 获取当天是这个月的第几天
  public static int getNowMonth(long time){
	     int month = 1;
	     Date date = new Date(time); 
	     Calendar calendar = Calendar.getInstance(); 
	     calendar.setTime(date);
	     month = calendar.get(Calendar.WEEK_OF_MONTH);
	     return month;
  } 
  // 获取当天是第几个月
  public static int getNMonth(long time){
	     int month = 1;
	     Date date = new Date(time); 
	     TimeZone china=TimeZone.getTimeZone("GMT+08:00"); //时区设置
	     Calendar calendar = Calendar.getInstance(china); 
	     calendar.setTime(date);
	     month = calendar.get(Calendar.MONTH);
	     return month;
} 
   
  // k线底部日期的显示格式
  public static String getButtomDate(String timeStr){
		 String str = "";
		 String mon = timeStr.substring(4, 6);
		 String day = timeStr.substring(6, 8);
	     str =   mon +"/"+ day;
	     return str;
 }  
  // step = 时差的大小  type=0 向前  type=1向后
  public static long getTimeCha(long step,int type){
 	 long ret = 0;
 	 long now = System.currentTimeMillis();  //获取当前的时间种子
 	 if(type==0){
 		 ret = now + step;
 	 }else{
 		 ret = now - step;
 	 }	 
 	 return ret; 
  } 
  // 获取时间,精确到分钟  
  public static String getStrTime(long timess){
 	  String str = "";
 	  Date date = new Date(timess);
 	  TimeZone china=TimeZone.getTimeZone("GMT+08:00"); //时区设置
      Calendar calendar = Calendar.getInstance(china);
      calendar.setTime(date); 
      String hour  = String.valueOf(calendar.get(Calendar.HOUR_OF_DAY));
      String minute  = String.valueOf(calendar.get(Calendar.MINUTE));
      if(minute.length()==1){
     	 minute = "0"+minute;
      }
      if(hour.length()==1){
     	 hour = "0"+hour;
      }  
      str = hour + ":" + minute;
     return str;
  } 
  // 获取分时时间,当天0点开始
  public static long getNowDayZone(){
	     long  time = System.currentTimeMillis(); 
	     Date date = new Date(time);  
	     TimeZone china=TimeZone.getTimeZone("GMT+08:00"); //时区设置
	     Calendar calendar = Calendar.getInstance(china); 
	     calendar.setTime(date); 
	     calendar.set(Calendar.HOUR_OF_DAY, 0); 
	     calendar.set(Calendar.MINUTE, 0); 
	     calendar.set(Calendar.SECOND, 0); 
	     return calendar.getTime().getTime(); 
  } 
  /***
   * 根据设置获取当天的时间
   * @param  h = 小时;m = 分钟; s = 秒;
   * @return long 当前时间所代表的毫秒数
   * ***/
  public static long getTimesDataBySet(int h,int m,int s){
	     long  time = System.currentTimeMillis(); 
	     Date date = new Date(time);  
	     TimeZone china=TimeZone.getTimeZone("GMT+08:00"); //时区设置
	     Calendar calendar = Calendar.getInstance(china); 
	     calendar.setTime(date); 
	     calendar.set(Calendar.HOUR_OF_DAY, h); 
	     calendar.set(Calendar.MINUTE, m); 
	     calendar.set(Calendar.SECOND, s); 
	     return calendar.getTime().getTime(); 
 } 
  
  /***
   *  判断今天天是星期几
   * @param  d = 天  2 ==星期1, 6 ==星期5
   * @return long 当前时间所代表的毫秒数
   * ***/
  public static int getWeekDayBySet(){    
	     int week = 1;
	     long t = System.currentTimeMillis(); 
	     Date date = new Date(t); 
	     Calendar calendar = Calendar.getInstance(); 
	     calendar.setTime(date);
	     week = calendar.get(Calendar.DAY_OF_WEEK); 
	     return   week;
 }  
	/*  
	 *  判断一下时间是否在开盘时间内
	 * 
	 */ 
	public static boolean isOpenTime(){   
	  long t = System.currentTimeMillis(); 
	  int a = getWeekDayBySet();	// 如果这个数字在2-6之间,则符合要求		
	  long	amOpen = getTimesDataBySet(9, 30, 0);
	  long	amClose = getTimesDataBySet(11, 30, 0);
	  long	pmOpen =  getTimesDataBySet(13, 0, 0);
	  long  pmClose = getTimesDataBySet(15, 0, 0);
	//  System.out.println(" === week == " + a + " t = "+ t +"  pmOpen = " + pmOpen);
	   
	  if(a>1&&a<7){
		  if((t>=amOpen&&t<=amClose)||(t>=pmOpen&&t<=pmClose)){ 
			   return true;  // 只有日期在周一到周五之间,时间为开盘时间的时候才会执行数据刷新
		  }else{ 
			   return false;
		  }  
	  }else{
		  return false;
	  }
	} 
	
	public static boolean isOpenT(){   
		  long t = System.currentTimeMillis(); 
		  int a = getWeekDayBySet();	// 如果这个数字在2-6之间,则符合要求		
		  long	amOpen = getTimesDataBySet(9, 30, 0); 
		  long  pmClose = getTimesDataBySet(15, 0, 0);
		//  System.out.println(" === week == " + a + " t = "+ t +"  pmOpen = " + pmOpen);
		   
		  if(a>1&&a<7){
			  if((t>=amOpen&&t<=pmClose)){ 
				   return true;  // 只有日期在周一到周五之间,时间为开盘时间的时候才会执行数据刷新
			  }else{ 
				   return false;
			  }  
		  }else{
			  return false;
		  }
		} 
  
  /*********** 日期类型格式转换以及时差参数处理 end ************/
  /*** 
   * 数据排序算法
   * ***/
	 /**
	  * 冒泡排序
	  * @input 一个未排序的数组
	  *
	  * @return 按照从小到大排序完成的数组
	  */
	 public static int[] doSort(int source[]) {
	  int length = source.length;
	  for (int i = length - 1; i > 1; i--) {
	   for (int j = 0; j < i; j++)
	    if (source[j] > source[j + 1]) {
	     int tmp = source[j];
	     source[j] = source[j + 1];
	     source[j + 1] = tmp;
	    }
	  }
	  return source;
	 } 
	 // float 类型的方法重载 
	 public static float[] doSort(float source[]) {
		  int length = source.length;
		  for (int i = length - 1; i > 0; i--) {
		   for (int j = 0; j < i; j++)
		    if (source[j] > source[j + 1]) {
		     float tmp = source[j];
		     source[j] = source[j + 1];
		     source[j + 1] = tmp;
		    }
		  }
		  return source;
		 }    
	 
	// vector 类型的方法重载 
	 public static Vector doKLineVectorSort(Vector vv) {
		  Vector vvs = new Vector();
		  int size = vv.size();
		  for(int i=size-1;i>=0;i--){
			  vvs.addElement(vv.elementAt(i));
		  }		  
		  return vvs;
	 }  
	// 过滤特殊字符
	 public static String filterString(String str){
		 StringBuffer buffer = new StringBuffer();
		 String filter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		 char c,cc;  
		 for (int i = 0; i < str.length(); i++) {
	         c = str.charAt(i);
	       //  System.out.println( i + " == " + c);
	         if(c<'0'||c>'9'){
	        //	 System.out.println("含有非法字符:" + c); 
	        	 for(int j=0;j<26;j++){
	         		cc = filter.charAt(j);
	         		if(cc==c){
	         			buffer.append(c);
	         		}
	         	 }     
	         }else{
	        	buffer.append(c); 
	         }
	     }
		 return buffer.toString();
	 }
	 
	 // 数据处理,去空和替换特殊字符 &#8220;="  &#8221;" ,'\0'
	 public static String getFilterText(String src){
	    	// 先替换字符
	      String str = src.trim();
	      String str1 =	DataTypeChange.replace(str, "&#8220;", "\"");
	      String str2 = DataTypeChange.replace(str1, "&#8221;", "\"");
	      String str3 = DataTypeChange.replace(str2, "&#183;", "."); 
	   /*   StringBuffer buffer = new StringBuffer();
	      char c;
	      char fi = '\0';
	      for(int i=0;i<str3.length();i++){
	    	  c = str3.charAt(i);
	    	  if(c!=fi){// 如果存在\0则跳过添加
	    		  buffer.append(c);
	    	  }
	      }
	       buffer.toString();
	      */
	      return str3;
	    }    
	 
}

 

分享到:
评论

相关推荐

    JAVA字符串操作类CTool.java字符转换类.rar

    JAVA字符串操作类CTool.java字符转换类,此类中收集Java编程中WEB开发常用到的一些工具。为避免生成此类的实例,构造方法被申明为private类型的。封装的功能:字符串从GBK编码转换为Unicode编码、对字符串进行md5...

    DataUtil--数据工具类--数据类型判断和比较

    DataUtil--数据工具类--数据类型判断和比较,包括判断字符串是否为空,判断字符串不为空,判断是否为数字,判断是否为整型数字,判断是否为日期字符串(格式如:2014-04-01),判断是否为时间字符串(格式如:2014-...

    Java CTool.java一个好用的字符串操作类.rar

    这个类的功能可实现将数据从数据库中取出后转换、字符编码转换、大文本块处理(将字符集转成ISO)、字符类型转换,比如将String型变量转换成int型变量等操作,在实际应用中,这是个相当实用的字符串操作类。

    java实现将实体类list集合,转化成geojson字符串

    GeoJSON是一种对各种地理数据结构进行编码的格式,基于Javascript对象表示法(JavaScript Object Notation, 简称JSON)的地理空间信息数据交换格式...该工具可以实现通过java代码将任意的实体类数据集合生成GeoJSON字符串

    Java文件处理工具类--FileUtil

    * 读取文件并返回为给定字符集的字符串. * @param fileName * @param encoding * @return * @throws Exception */ public static String readFileAsString(String fileName, String encoding) throws ...

    javaweb项目常用工具包

    Base64工具类-字符编码工具类-数据类型转换-日期工具类-Escape中文转码工具类-fastjson工具类-文件工具类-Http工具类-http请求工具类-用于模拟HTTP请求中GET/POST方式 -图片处理工具类-Ip工具类-mail工具类-Map工具...

    Java开发常用Util工具类

    字符串工具类/数据类型转换类/集合工具类/数组工具类/Properties文件操作类/常用流操作工具类/编码工具类/Json工具类/日期工具类/下载文件工具类/解压ZIP工具类/文件编码转码

    Java - DateUtil 日期时间转换工具类

    内容概要:日期时间转换工具类,包括基本的Date类型,String类型,TimeStamp类型,LocalDateTime类型,LocalDate类型之间的互相转换,还提供了许多与时间获取,时间计算有关的方法,如:获取指定日期几天后的日期;...

    java常用工具类的使用

    而在Java类库中有一个Arrays类的sort方法已经实现各种数据类型的排序算法。程序员只需要调用该类的方法即可。 代码演示:Arrays实现排序 public static void main(String[] args) { int[] ages={23, 45,12,76,34,...

    java程序设计实验指导代码

    第2章 基本数据类型和基本运算 2.1 预备知识 2.2 实验 基本运算练习 第3章 控制语句 3.1 预备知识 3.2 实验1 评判学生成绩等级 3.3 实验2 输出九九乘法表 第4章 数组 4.1 预备知识 4.2 实验1 数组排序 4.3 实验...

    JAVA_API1.6文档(中文)

    java.util 包含 collection 框架、遗留的 collection 类、事件模型、日期和时间设施、国际化和各种实用工具类(字符串标记生成器、随机数生成器和位数组)。 java.util.concurrent 在并发编程中很常用的实用工具类...

    Java开发技术大全(500个源代码).

    代码范例列表 第1章 示例描述:本章演示如何开始使用JDK进行程序的开发。 HelloWorldApp.java 第一个用Java开发的应用程序。 firstApplet.java 第一个用... demoForceChange.java 演示强制类型转换 demoGeneric.java ...

    通用Android工具库Common4Android.zip

    Bitmap常用工具类,Bitmap数据类型转换、圆角、缩放、倒影。 ConvertUtil.java 转换工具类,进行对象的类型转换。 DateUtil.java 日期工具类,...

    Java 1.6 API 中文 New

    java.util 包含 collection 框架、遗留的 collection 类、事件模型、日期和时间设施、国际化和各种实用工具类(字符串标记生成器、随机数生成器和位数组)。 java.util.concurrent 在并发编程中很常用的实用工具类。...

    java api最新7.0

    java.util 包含 collection 框架、遗留的 collection 类、事件模型、日期和时间设施、国际化和各种实用工具类(字符串标记生成器、随机数生成器和位数组)。 java.util.concurrent 在并发编程中很常用的实用工具类。...

    Android静默安装常用工具类

    Android SharedPreferences相关工具类,可用于方便的向SharedPreferences中读取和写入相关类型数据,如: putString(Context, String, String) 保存string类型数据 putInt(Context, String, int) 保存int类型数据 ...

    JavaAPI1.6中文chm文档 part1

    java.util 包含 collection 框架、遗留的 collection 类、事件模型、日期和时间设施、国际化和各种实用工具类(字符串标记生成器、随机数生成器和位数组)。 java.util.concurrent 在并发编程中很常用的实用工具类...

    JAVA上百实例源码以及开源项目源代码

     设定字符串为“张三,你好,我是李四”  产生张三的密钥对(keyPairZhang)  张三生成公钥(publicKeyZhang)并发送给李四,这里发送的是公钥的数组字节  通过网络或磁盘等方式,把公钥编码传送给李四,李四接收到...

    JAVA语言程序设计【高清版】.pdf

    186 9.3.3 Applet与URL 187 9.4 在Applet中的多媒体处理 188 9.4.1 在Applet中显示图像 188 9.4.2 在Applet中播放声音 189 9.5 Applet的事件处理 189 习题 191 第10章 Java数据流 192 10.1 数据流的...

Global site tag (gtag.js) - Google Analytics