프로젝트에서는 종종 수신 된 문자열을 해당 컬렉션 클래스로 변환하여 저장하거나 컬렉션 클래스를 문자열로 변환하여 쉽게 전송해야합니다. 이 도구 클래스는 일반적으로 사용되는 몇 가지 방법을 캡슐화 하여이 변환 요구 사항에 매우 편리합니다.
import java.util.arrays; import java.util.collection; import java.util.hashmap; import java.util.hashset; import java.util.map; import java.util.properties; import java.util.set; import java.util.treeset; public classe { /** convertis {confernding {convertis the thringUtils mystringUtils. Delimiter는 모든 공백 문자*/ public static set <string> parseparameterList (문자열 값) {set <string> result = new Treeset <string> (); if (values! = null && values.trim (). length ()> 0) {// 사양은 스코프가 공백으로 분리되어 있다고 말합니다 [] tokens = values.split ( "[// s+]"); // 모든 흰색 whitespace char } 반환 결과; } / *** 컬렉션을 지정된 양식의 문자열로 변환* / public static String formatparameterList (collection <string> value) {return value == null? null : stringUtils.collectionTodelItedString (value, ","); // Delimiter를 지정}/*** 쿼리 문자열에서 필요한 키 값 쌍을 추출하고 Query Name = 111 & method = up*/public static map, string> extristmap (map <string, newshm <string, newshm <string, newshmap). 문자열> (); 속성 속성 = StringUtils.splitArrayElementsIntOproPerties (stringUtils.delimitedListToStringArray (query, "&"), "="); if (properties! = null) {for (개체 키 : properties.keyset ()) {map.put (key.toString (), properties.get (key) .toString ()); }} 리턴 맵; } / *** 두 세트가 동일한지 여부를 비교* / public static boolean incoperall (set <string> target, set <string> members) {target = new Hashset <string> (target); target.retainall (멤버); // 두 세트의 교차점을 가져옵니다. Return.Size () == members.size (); }}일반적으로 사용되는 문자열과 수집 변환이있는 도구 클래스에 대한 위의 간단한 논의는 내가 공유하는 모든 컨텐츠입니다. 나는 그것이 당신에게 참조를 줄 수 있기를 바랍니다. 그리고 당신이 wulin.com을 더 지원할 수 있기를 바랍니다.