Try-Catch While Loop,Catch不允许新输入?

时间:2017-04-27 01:16:26

标签: java try-catch

try {
    while ((inputLine = bufferedReader.readLine()) != null) {
    String[] words = inputLine.split("[ \n\t\r.,;:!?(){}]");

    for (int wordCounter = 0; wordCounter < words.length; wordCounter++) {
        String key = words[wordCounter].toLowerCase();
        if (key.length() > 0) {
            if (map.get(key) == null) {
                map.put(key, 1);
            }
            else {
                int value = map.get(key).intValue();
                value++;
                map.put(key, value);
            }
        }

        Set<Map.Entry<String, Integer>> entrySet = map.entrySet();

        for (Map.Entry<String, Integer> entry : entrySet) {
            System.out.println(entry.getValue() + "\t" + entry.getKey());
        }
    }
} catch (IOException error) {
    System.out.println("Invalid File"); 
}

1 个答案:

答案 0 :(得分:2)

重构你的循环,以便提示用户在循环中输入新的

import os
.
.
.
path = os.path.abspath('myName/artefacts/Images/UIheader02.png')
cmds.image( image=path )