NumberFormat usFormat = NumberFormat.getIntegerInstance(Locale.US);
//使用美國格式
String number = usFormat.format(1000)
//將1000轉為美國格式
System.out.println(number);
//結果1,000
2011年7月27日 星期三
URLConnection應用,與遠端做資料溝通
//傳送物件到遠端
URL url = new URL("遠端網址");
URLConnection urlConnection = url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setUseCaches(false);
urlConnection.setDefaultUseCaches(false);
urlConnection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
ObjectOutputStream ous = new ObjectOutputStream(urlConnection.getOutputStream());
ous.writeObject(cgsNums);
ous.writeObject(qcOrders);
ous.writeObject(cpdtOwner);
ous.flush();
ous.close();
//遠端將資料組合後
//讀取網頁
StringBuffer html = new StringBuffer();
BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String inputLine;
while ((inputLine = br.readLine()) != null) {
html.append(inputLine).append("\r\n");
}
URL url = new URL("遠端網址");
URLConnection urlConnection = url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setUseCaches(false);
urlConnection.setDefaultUseCaches(false);
urlConnection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
ObjectOutputStream ous = new ObjectOutputStream(urlConnection.getOutputStream());
ous.writeObject(cgsNums);
ous.writeObject(qcOrders);
ous.writeObject(cpdtOwner);
ous.flush();
ous.close();
//遠端將資料組合後
//讀取網頁
StringBuffer html = new StringBuffer();
BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String inputLine;
while ((inputLine = br.readLine()) != null) {
html.append(inputLine).append("\r\n");
}
2011年7月25日 星期一
JQuery checkbox 應用
每次都忘記JQuery對checkbox操作的寫法,下定決心把他寫起來
取得已勾選的數量
$('input[type=checkbox][name=cpdtNum]:checked').length
檢查checkbox使否已被勾選
$(obj).is(':checked')
取得已勾選的數量
$('input[type=checkbox][name=cpdtNum]:checked').length
檢查checkbox使否已被勾選
$(obj).is(':checked')
訂閱:
文章 (Atom)