Regular Express 簡介
範例:
檢查日期格式 1900/1/12:/^\d{4}\/\d{1,2}\/\d{1,2}$/
檢查信用卡號 xxxx-xxxx-xxxx-xxxx:/^\d{4}-\d{4}-\d{4}-\d{4}$/
檢查身分證號碼 A000000000 : /^[A-Z]\d{9}$/
檢查IP格式 : /^\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b$/
檢查僅能輸入英文數字格式 : /^\w{1,}$/
2007/04/23
2007/04/09
Windows - 最佳化虛擬記憶體
如果要讓 Windows 選擇最佳的分頁檔大小,請按一下 [系統管理大小]。
建議的最小值為您電腦上 RAM 的 1.5 倍,而最大值則為這個數字的 3 倍。
例如,假設您有 256 MB 的 RAM,則最小值應為 384 MB,最大值應為 1152 MB。
建議的最小值為您電腦上 RAM 的 1.5 倍,而最大值則為這個數字的 3 倍。
例如,假設您有 256 MB 的 RAM,則最小值應為 384 MB,最大值應為 1152 MB。
2007/04/03
判斷檔案的 ContentType/MIME-Type
import javax.activation.MimetypesFileTypeMap;
import java.io.File;
class GetContentType {
public static void main(String args[]) {
File f = new File("gumby.gif");
System.out.println("Mime Type of " + f.getName() + " is " +
new MimetypesFileTypeMap().getContentType(f));
// "Mime Type of gumby.gif is image/gif"
}
}
[註]有可能會mapping不到資料,可以查詢j2ee api : javax.activation.MimetypesFileTypeMap。MIME types
import java.io.File;
class GetContentType {
public static void main(String args[]) {
File f = new File("gumby.gif");
System.out.println("Mime Type of " + f.getName() + " is " +
new MimetypesFileTypeMap().getContentType(f));
// "Mime Type of gumby.gif is image/gif"
}
}
[註]有可能會mapping不到資料,可以查詢j2ee api : javax.activation.MimetypesFileTypeMap。MIME types
2007/03/28
DataBase - 存取檔案至資料庫 (mssql2000)
環境:
DB : mssql 2000
Table schema :
id int,
fileContent image,
path varchar(255);
從檔案加入至資料庫
code:
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433", "cf-intermediate",
"cf-intermediate");
File file = new File("C:/MyEclipse5.1/workspace/myJava/abc.doc");
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
// 將檔案讀入位元陣列
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[1];
while (bufferedInputStream.read(bytes) != -1) {
arrayOutputStream.write(bytes);
}
arrayOutputStream.close();
bufferedInputStream.close();
bytes = arrayOutputStream.toByteArray();
System.out.println("bytes="+bytes.length);
PreparedStatement preState = con.prepareStatement("insert into erpglm_append values(?,?,?)");
preState.setBytes(1, bytes);
preState.setString(2, file.getPath());
preState.setString(3, "N");
preState.execute();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
從資料庫取得資料並存成檔案:
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433", "cf-intermediate",
"cf-intermediate");
String sql = "select fileContent from erpglm_append where id=1";
Statement stat = con.createStatement();
ResultSet rs = stat.executeQuery(sql);
byte[] bytes = null;
while (rs.next()) {
bytes = (byte[]) rs.getObject("fileContent");
}
rs.close();
stat.close();
con.close();
System.out.println("bytes="+bytes.length);
BufferedInputStream bufferedInputStream = new BufferedInputStream(new ByteArrayInputStream(bytes));
File file = new File("C:/MyEclipse5.1/workspace/myJava/abc1.doc");
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
byte[] data = new byte[1];
while (bufferedInputStream.read(data) != -1) {
bufferedOutputStream.write(data);
}
bufferedOutputStream.flush();
bufferedInputStream.close();
bufferedOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
DB : mssql 2000
Table schema :
id int,
fileContent image,
path varchar(255);
從檔案加入至資料庫
code:
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433", "cf-intermediate",
"cf-intermediate");
File file = new File("C:/MyEclipse5.1/workspace/myJava/abc.doc");
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
// 將檔案讀入位元陣列
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[1];
while (bufferedInputStream.read(bytes) != -1) {
arrayOutputStream.write(bytes);
}
arrayOutputStream.close();
bufferedInputStream.close();
bytes = arrayOutputStream.toByteArray();
System.out.println("bytes="+bytes.length);
PreparedStatement preState = con.prepareStatement("insert into erpglm_append values(?,?,?)");
preState.setBytes(1, bytes);
preState.setString(2, file.getPath());
preState.setString(3, "N");
preState.execute();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
從資料庫取得資料並存成檔案:
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433", "cf-intermediate",
"cf-intermediate");
String sql = "select fileContent from erpglm_append where id=1";
Statement stat = con.createStatement();
ResultSet rs = stat.executeQuery(sql);
byte[] bytes = null;
while (rs.next()) {
bytes = (byte[]) rs.getObject("fileContent");
}
rs.close();
stat.close();
con.close();
System.out.println("bytes="+bytes.length);
BufferedInputStream bufferedInputStream = new BufferedInputStream(new ByteArrayInputStream(bytes));
File file = new File("C:/MyEclipse5.1/workspace/myJava/abc1.doc");
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
byte[] data = new byte[1];
while (bufferedInputStream.read(data) != -1) {
bufferedOutputStream.write(data);
}
bufferedOutputStream.flush();
bufferedInputStream.close();
bufferedOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
2007/03/26
XDoclet - sql-type 用法
/**
* @hibernate.property name="chtName" not-null="true"
* @hibernate.column name="chtName" sql-type="nvarchar(50)"
*/
欄位長度均由sql-type中給定
* @hibernate.property name="chtName" not-null="true"
* @hibernate.column name="chtName" sql-type="nvarchar(50)"
*/
欄位長度均由sql-type中給定
2007/03/23
彈跳視窗
1.使彈跳視窗為全螢幕:
window.open("2.html", "page2", "fullscreen=1");
2.使彈跳視窗最大化:
var param = "hight="+screen.availHeight+",width="+screen.availWidth;
window.open("2.html", "page2", param);
3.使彈跳視窗設定座標:
window.open("2.html", "page2", "top=0,left=0");
window.open("2.html", "page2", "fullscreen=1");
2.使彈跳視窗最大化:
var param = "hight="+screen.availHeight+",width="+screen.availWidth;
window.open("2.html", "page2", param);
3.使彈跳視窗設定座標:
window.open("2.html", "page2", "top=0,left=0");
2007/03/12
Windows - 佈景主題
XPize is a GUI enhancer that replaces most of the non-XP icons, avis and bmps that Microsoft has always overlooked. It also includes some extras and a reloader, which you can use after visiting Windows Update.
訂閱:
文章 (Atom)
NGINX SSL/設定檔案
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #...
-
Source: Automatically Retry Failed Jobs in Quartz Retrying continuously until success: If you want to keep trying over and over again un...
-
*主餐類 漢堡王炸雞腿-227大卡 華嫩雞條(6PCS)-259大卡 火烤漢堡-311大卡 火烤吉士漢堡-353大卡 小華堡-397大卡 華雪魚-471大卡 雙層吉士漢堡-534大卡 雙層燒烤培根堡-580大卡 華辣雞腿堡-597大卡 華香雞排堡-685大卡...
-
Download source files from here Upload files to the CentOS server Prepare the necessary files #yum -y install gcc gcc-c++ autoconf lib...