?? pureutil.java.svn-base
字號:
package com.pure.util;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PureUtil {
/**
* 調試輸出
*
* @param msg
*/
public static void debug(Object msg) {
System.out.println(msg);
}
/**
* 格式化日期
*
* @param formart
* @return 格式化后的日期字符串
*/
public static String getDateFormatStr(String formart) {
return new SimpleDateFormat(formart).format(new java.util.Date());
}
/**
* 刪除指定文件名的文件
*
* @param fileName
*/
public static void delFile(String fileName) {
if (null == fileName || "".equals(fileName))
return;
File delFile = new File(fileName);
if (delFile.isFile()) {
if (delFile.exists()) {
delFile.delete();
}
}
}
/**
* 刪除指定文本中含有的上傳文件
*
* @param content
* @param path
*/
public static void delUploadFile(String content, String path) {
if (null == content || "".equals(content))
return;
String regex = "[0-9]{1,30}.(doc|jpg|gif)";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(content);
while (m.find()) {
delFile(path + m.group());
}
}
/**
* 產生唯一的文件名
*
* @return 返回一個唯一的文件名
*/
public static String getUploadFileName() {
String formart = "yyyyMMddHHmmss";
Random random = new Random();
String fileName = new SimpleDateFormat(formart)
.format(new java.util.Date());
fileName += Math.abs(random.nextInt()) % 100;
return fileName;
}
/**
* 截取指定文件名的擴展名
*
* @param fileName
* @return 返回截取的擴展名
*/
public static String getUploadFileEx(String fileName) {
if (null == fileName) {
return "";
} else {
if (fileName.lastIndexOf(".") != -1) {
return fileName.substring(fileName.lastIndexOf("."));
} else {
return "";
}
}
}
/**
* ISO編碼轉為GBK編碼
*
* @param str
* @return 轉換后的編碼
*/
public static String strEncodeISOTOGBK(String str) {
try {
String temp_p = str;
if (temp_p == null || "".equals(temp_p)) {
return "";
}
String temp = new String(temp_p.getBytes("ISO8859-1"), "GBK");
return temp;
} catch (Exception e) {
return null;
}
}
/**
* 列表行鼠標移上、移出的效果
*
* @return javascript 控制的css
*/
public static String trBgcolorMouseOverAndMouseOut() {
String str = "bgcolor=\"#FFFFFF\" onMouseOver=\"this.style.backgroundColor='#CDF2B9'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\" style='cursor:hand'";
return str;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -