努力学习第六天
单词接龙
public void wordWrite(int index, String path) throws Exception { MyFile file = new MyFile(); BufferedWriter bf = file.put(path); wordsList.add(words.get(index)); try { for (String string : words) { if (compare(wordsList.get(wordsList.size() - 1), string)) { wordsList.add(string); bf.append(string); bf.newLine(); } } bf.close(); } catch (IOException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } if (wordsList.size() <= 1) { throw new Exception("文件内无单词链"); } }