by Nathan
StringTokenizer 본문
1. code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public static void main(String[] args) { String delims = ","; String splitString = "1,2,,3,4,,5"; StringTokenizer st = new StringTokenizer(splitString, delims); while (st.hasMoreElements()) { System.out.println("StringTokenizer Output: " + st.nextElement()); } String[] tokens = splitString.split(delims); int tokenCount = tokens.length; for (int j = 0; j < tokenCount; j++) { System.out.println("Split Output: "+ tokens[j]); } } | cs |
2. result
1 2 3 4 5 6 7 8 9 10 11 12 | StringTokenizer Output: 1 StringTokenizer Output: 2 StringTokenizer Output: 3 StringTokenizer Output: 4 StringTokenizer Output: 5 Split Output: 1 Split Output: 2 Split Output: Split Output: 3 Split Output: 4 Split Output: Split Output: 5 | cs |
'Programming > JAVA' 카테고리의 다른 글
엑셀 다운로드(gradle, poi3.7) (0) | 2018.07.30 |
---|---|
엑셀 업로드(gradle, poi3.7) (0) | 2018.07.30 |
HTTP request (0) | 2017.03.20 |
Bubble sort (0) | 2017.03.17 |
request.getRemoteAddr() ipv4로 받기 (0) | 2016.06.13 |
Comments