2011年10月5日 星期三

HTC sensation 擷取手機畫面


按下手機上方電源鍵+主畫面鍵就可以擷取目前畫面
再到相簿中就可以看到擷取的畫面摟....

2011年9月29日 星期四

java JSONArray

import net.sf.json.JSONArray;
若是引用JSONArray套件似乎
要引用
ezmorph-1.0.6.jar
commons-collections-3.2.1.jar
json-lib-2.4-jdk15.jar

2011年5月5日 星期四

jsp匯出excel

1.下載jxl套件

2. jsp中

try {

String original_filename = "fileToOutput.xls";
String sRealPath = (String) original_filename;
//產生要存的excel
File file = new File(sRealPath);
//產生一檔案WritableWorkbook讓程式匯出
WritableWorkbook writableWorkBook = Workbook.createWorkbook(file);
//在檔案中開啟一新的sheet
WritableSheet writableSheet = writableWorkBook.createSheet("我是第一張sheet", 1);
//WritableSheet writableSheet2 = writableWorkBook.createSheet("我是第二張sheet", 2);
//設定寫入儲存格的字型大小
WritableFont chFont12w = new WritableFont(WritableFont.createFont("Times New Roman"), 12);
WritableCellFormat writableCellFormat = new WritableCellFormat(chFont12w);

//label中的(0,0)代表excel中的(A,0)
//label中的(1,0)代表excel中的(B,0)
//label中的(1,1)代表excel中的(B,1),以此類推
Label deptLabel = new Label(0, 0, "印出字串",writableCellFormat);
writableSheet.addCell(deptLabel);

//寫入EXCEL檔案
writableWorkBook.write();
//關閉檔案
writableWorkBook.close();


} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

2011年4月1日 星期五

httpclient file中文檔名上傳

要先認證(我用NTLM)

NTCredentials creds = new NTCredentials("帳", "密", "", "網域");
httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);


HttpPost httppost = new HttpPost("上傳目標位置");
httpclient.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET,"UTF-8");
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,HttpVersion.HTTP_1_1);
FileBody bin = new FileBody(new File(sourcePath),"","UTF-8");
StringBody title = new StringBody(fileName,Charset.forName("UTF-8"));

MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE,null,Charset.forName("UTF-8"));

reqEntity.addPart("file", bin);
reqEntity.addPart("fileTitle", title);

httppost.setEntity(reqEntity);

HttpResponse response = httpclient.execute(httppost);
EntityUtils.consume(resEntity);
try {
httpclient.getConnectionManager().shutdown();
} catch (Exception ee) {ee.printStackTrace(); }


***接收***
使用org.apache.commons.fileupload.FileItem 套件
怎麼接收檔案就不描述了
字串接收

if ("fileTitle".equals(item.getFieldName())) {
fileTitle = new String(item.getString().getBytes("ISO-8859-1"), "UTF-8");
}

檔案接收
可接收檔名

originalFileName = item.getName();
System.out.println("originalFileName:"+originalFileName);


有任何問題請留言或mail可以討論

2011年3月23日 星期三

2011年2月10日 星期四

createElement onclick function 參數

使用DOM時
需要動態加入onclick 啟動某個function
而此function必須傳參數進去
此範例是跑迴圈而每次nid皆不同
每次動態新增一個圖示而點擊圖示時執行popmenu(參數) function的動作

cImg=document.createElement('img');
cImg.id = 'img'+nid;
cImg.setAttribute("src","images/icon_folderclosed.gif");
cImg.alt=nName;
cImg.title=nid+","+nName;
cImg.onclick = Function("popmenu('"+nid+"');");

參考網址http://blog.yam.com/csylvia/article/23681942

2011年1月17日 星期一

sql 找出重複資料

同一table要找出num有重複的筆數可以下以下指令
select *
from user T1 where (select count(*) from user T2 where T1.num = T2.num) >1

2011年1月11日 星期二

java編譯執行

若是
classA加入
package a.b;
代表此class要放在\a\b目錄底下

並且classA有使用到外部c.jar
此jar檔放在d:\test1

預設路徑為d:\test
編譯時
D:\test>javac -cp d:\test1\c.jar d:\test1\a\b\classA.java
執行時
D:\test>java -cp d:\test1\c.jar;. a.b.classA

2011年1月7日 星期五

jsp 接收中文參數

網址列傳中文參數
可以利用這個方法轉換成正確編碼

String cname = new String(request.getParameter("cname").getBytes("ISO-8859-1"),"big5");

2011年1月4日 星期二

OCJP

12/29 考到ocjp 80分 pass

Exam Registration Summary
Please verify the following information:
Confirmation Number: TEESYD51DE
Candidate's Name: Yao-Chun Yu
Exam Name: Oracle Certified Programmer for the Java 2 Platform, SE 6.0
Client/Exam Number: Oracle 310-065
Exam Language: U.S. ENGLISH