Java 记事本创建一个包含几十个英语单词的小文章 文件题目test.txt 实现 1 从屏幕中输出每一个单词
推荐回答
12345678910111213141516public class readfile { public static void main(String[] args) throws IOException { File file = new File("D:\\test.txt"); BufferedReader reader = new BufferedReader(new FileReader(file)); String temp = null; StringBuffer sb = new StringBuffer(); while ((temp = reader.readLine()) != null) { sb.append(temp); } String[] text = sb.toString().split(" "); for (String string : text) { System.out.println(string); } reader.close(); }}