1

抱歉,这是一个简单的问题,我找不到我正在寻找的内容,可能是因为我不知道关键字是什么。

例如,我有一个 read.java,当我重定向文件时,它应该能够读取名为 quotes.txt 的文件中有多少个 A:read < quotes.txt

如何从 java 中的quotes.txt 中读取?

4

1 回答 1

1

You can use new Scanner(System.in). It will be available as Standard Input Stream for read, represented by System.in, which is a InputStream.

You can also do

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

and use that br.

于 2012-10-01T03:39:40.247 回答