求帮助。我这个代码好像冗余了。java

img


这个代码怎么改,我这个好像代码冗余了。 运行起来是一片空白。求解答谢谢

public static void main(String[] args) throws IOException {
String[] words = {"verb:eat","verb:drink","verb:sleep","verb:play","moun:meat","moun:hand","moun:hair"};
FileOutputStream outVerb = new FileOutputStream(new File("D:/test/verb.txt"),true);//最好写全路径
FileOutputStream outMoun = new FileOutputStream(new File("D:/test/moun.txt"),true);
byte[] bytes;
for(int i = 0;i<words.length;i++){
bytes = words[i].substring(5).getBytes();
if(words[i].startsWith("verb")){
outVerb.write(bytes);

        }else {
            outMoun.write(bytes);

        }

    }
    outMoun.close();
    outVerb.close();
}

然后执行的结果会在D盘下的test目录下,生成两个文件.由于你的代码没有输出,所以控制台只能是一片空白

记得关流