Hello,
I dont know what to do next..
I tried in several ways.
Please help.
package pl.codegym.task.task13.task1319;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
/*
Zapisywanie do pliku z konsoli
*/
public class Solution {
public static ArrayList<String> list = new ArrayList<>();
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String fileName = reader.readLine();
FileWriter fileWriter = new FileWriter(fileName);
BufferedWriter writer = new BufferedWriter(fileWriter);
String text;
while (!(text = reader.readLine()).equals("exit")) {
for (int i = 0; i < list.size(); i++) {
if (i < list.size() - 1) {
writer.write(text + "\n");
writer.append(' ');
list.add(text);
}
}
}
for (String values : list
) {
System.out.println(values);
}
writer.close();
}
}