There's no such convenience method in the standard Java API.
But, All the references to Apache Commons are fine.
Use the library 「org.apache.commons.lang.StringUtils」.
List:
List<String> list = Arrays.asList("342443","342450","342449");
System.out.println(StringUtils.join(list, ","));
// 342443,342450,342449
Map:
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("342443", 23);
map.put("342450", 672);
map.put("342449", 15);
// join keys
System.out.println(StringUtils.join(map.keySet(), ","));
// 342443,342450,342449
// join valus
System.out.println(StringUtils.join(map.values(), ","));
// 23,672,15
Lamb & Vampire
羊咩咩與吸血鬼
2014年9月24日 星期三
Java:convert List/Map to a join string
2014年7月15日 星期二
The default Context Path on 『Add & Remove Available Resource』set Tomcat with Eclipse.
When I use the『Add and Remove...』function on Server with IDE Eclipse.
I always have to rewrite the default Context Path on file server.xml.
Ex:
Before:
<Context docBase="test" path="/test" reloadable="true" source="org.eclipse.jst.jee.server:test"/></Host>
After:<Context docBase="test" path="/" reloadable="true" source="org.eclipse.jst.jee.server:test"/></Host>
If I want do it once.
Find the file 『org.eclipse.wst.common.component』 where located in folder 『.setting』.
The content is like:
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="test">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="context-root" value="test"/>
<property name="java-output-path" value="/test/build/classes"/>
</wb-module>
</project-modules>
Just rewrite the fragment:
『<property name="context-root" value="test"/>』
to ^^^^
『<property name="context-root" value="xxxx"/>』
Done.
Another way.
Right click on your 『Dynamic Web Project』.
Choose 『properties...』→『Web Project Settings』.
Rewrite the Content on 『Context root』.
Much easier.
Done.
2012年3月7日 星期三
Eclipse 加入 tomcat 做法
要新增server之前,要先看到『Servers』View,「WindowàShow ViewàServers」如右圖:
然後在『Servers』View中按右鍵新增一個Server,如右圖:
開啟『New Server』視窗後,選一個開發的伺服器;這裡我選的是『Tomcat v7.0 Server』;如右圖:
Server's host name: 預設是【localhost】
Server name: 預設是【Tomcat v7.0 Server at localhost】
Server runtime environment: 【Apache Tomcat v7.0】
要加入對應的 Tomcat,要按下【Add...】;如右圖紅框所示:
開啟『New Server Runtime Environment』後,選擇 Tomcat 的所在位置;如右圖:
新增後,在『Package Explorer』View 中會顯示【Servers】,而『Servers』View 中則會顯示【Apache Tomcat v7 at localhost】;如右圖紅框所示:
在『Servers』View 的【Apache Tomcat v7 at localhost】上按【F3】開啟,或是滑鼠左鍵連擊兩次開啟如右圖之視窗;在《Server Locations》中選擇【Use Tomcat installation (takes control of Tomcat installation)】,其餘欄位資料為預設帶出;如右圖:
如 8080 port 被佔住,亦可以在此做修改;如右圖紅框所示。
完成 Server 基本設定後,接下來要把專案掛到 Server 上,在【Apache Tomcat v7 at localhost】上按右鍵點選【Add and Remove】開啟,如右圖:
開啟【Add and Remove...】後,選擇要加入的專案;如右圖:
加入完成後,在『Package Explorer』View中可以找到【server.xml】檔,連擊滑鼠左鍵開啟後,可看到
前述步驟完成後,開啟 tomcat 資料夾,會發現多了一個【wtpwebapps】資料夾,這是因為在前步驟中有指定要執行的位置;如右圖:
要啟動Server了,首先在【Apache Tomcat v7 at localhost】上按右鍵點選【Clean Tomcat Work Directory】清除暫存程式資料檔;如右圖:
前一步驟目的是清除暫存程式資料,所在位置如右圖所示:
然後在【Apache Tomcat v7 at localhost】上按右鍵點選【Clean...】清除專案程式資料檔;如右圖:
最後按【Start】啟動 server。
如啟動過程中跳出如右圖之警告訊息視窗,這只是表示無法在45秒內完成啟動,可以無需理會重新啟動 server 。
如要拉長啟動時間,可在【Timeouts】中設定,如右圖:
正常啟動後,【Console】View 中會顯示對應的專案名稱,這裡我加入了ecs、mng 及mcs 等三個專案,所以三個專案在正常啟動後都會顯示如右圖的訊息。
啟動後,在【Servers】View 中的 icon 會顯示執行中,如右圖所示。
到此,Server 已正常啟動完成。
2011年6月15日 星期三
PMP 4th edition 筆記分享-(chapter 5)
PMP 4th edition 筆記分享-(chapter 4)
| ||||||||
| ||||||||
| ||||||||
| ||||||||
| ||||||||
| ||||||||
|