?? utilities.java
字號:
package client.chaowei.intraweb.bean.util;
import java.util.Date;
import java.text.SimpleDateFormat;
import client.chaowei.intraweb.bean.data.*;
import java.net.*;
import java.io.*;
public class Utilities {
/**
* 為文件名添加時間標記,主要用于附件上傳時防止文件重名
* @param fileName
* @return
*/
public String addTimeStampToFileName(String fileName) {
// 文件名稱中擴展名前面的"."的位置
int dotIndex = fileName.lastIndexOf(".");
// 文件名稱(不包括擴展名)
String firstPart = fileName.substring(0,dotIndex);
// 文件的擴展名
String secondPart = fileName.substring(dotIndex+1);
// 獲取當前系統時間
Date d = new Date();
// 轉換日期格式為:"yyyyMMddhhmmss"
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
String now = sdf.format(d);
fileName = firstPart+now+"."+secondPart;
return fileName;
}
/**
* 獲得指定用戶ID的部門名稱
* @param userId 用戶ID
* @return 部門名稱
*/
public String getOrg(String userId){
OracleConnection oraconn = new OracleConnection();
String sql = "select org from pa_emp_employee where id='"+userId+"'"; //查詢id等于用戶id的部門名稱
String org = oraconn.getSnglRowSnglCol(sql,"org",0);
return org;
}
/**
*
*/
public String skyReport(String sTotalString) {
int firstPlace = sTotalString.indexOf("連云港市氣象臺");
int secPlace = sTotalString.indexOf("預報值班員");
String skyReport = sTotalString.substring(firstPlace,secPlace);
//skyReport.replaceAll("內部資料","");
//skyReport.replaceAll("海上大風警報","");
//skyReport.replaceAll("轉發必究","");
//skyReport.replaceAll("───────────────────────","");
//skyReport.replaceAll("<br>","");
//skyReport.replaceAll(" ","");
skyReport = this.Replace(skyReport,"內部資料","");
skyReport = this.Replace(skyReport,"海上大風警報","");
skyReport = this.Replace(skyReport,"轉發必究","");
skyReport = this.Replace(skyReport,"───────────────────────","");
skyReport = this.Replace(skyReport,"<br>","");
skyReport = this.Replace(skyReport," ","");
//skyReport.replace('chr(13)&chr(10)','\n');
return skyReport;
}
public static String Replace(String str, String oldWord, String newWord) {
String tempStr = new String(str);
int pos = tempStr.indexOf(oldWord);
while (pos > -1) {
tempStr = tempStr.substring(0, pos) + newWord +
tempStr.substring(pos + oldWord.length());
pos = tempStr.indexOf(oldWord, pos + newWord.length());
}
return tempStr;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -