Android 用空格作为分割符切割字符串
项目中有需要用到空格作为分割符切割字符串,进而转为List。
        String wordStore = edWord.getText().toString();
        String[] word = wordStore.split("\\s+");
        List<String> wordsList = Arrays.asList(word);
会出现用户在输入的时候不小心多输入了一个、两个甚至多个空格的情况,单用一个“ ”字符来作分割符是不够的,以上方法可以完美解决该情况。
    The one who wants to wear the crown, bears the crown.
                    
                
                
            
        
浙公网安备 33010602011771号