私の入力が
今こそ、
すべての善良な男性が党を助けに来る時です
出力は次のようになります。
時間のために、今
のパーティーは、すべての良い人に来て、援助の
テキストファイル全体をそれぞれ逆にする方法を見つけましたが、文ごとに行う必要があります。現在、私のコードはこれを出力しています:
パーティー の 援助 の 人々 に 来る 時間 のために すべて 良い 今
コードは次のとおりです。
List<String> words = new ArrayList<String>();
while(sc.hasNextLine())
{
String line = sc.nextLine();
StringTokenizer st = new StringTokenizer(line);
while(st.hasMoreTokens())
{
words.add(st.nextToken());
}
}
for (int i = 0; i <words.size(); i++)
{
System.out.print(words.get(words.size()-i-1) + " ");
}