How to read text from a .txt file and then transfer data from it to an array?

Stuck on this:

 package Project_2402; import java.io.FileReader; import java.io.IOException; public class Programm { public static void main(String[] args) { try(FileReader reader = new FileReader("input.txt")) { //читаем посимвольно int c; while((c = reader.read())!=-1){ System.out.print((char)c); } } catch(IOException ex){ System.out.println(ex.getMessage()); } } } 

    1 answer 1

     public static void main(String[] args) { try (Stream<String> lineStream = Files.newBufferedReader(Paths.get("input.txt"), Charset.defaultCharset()).lines()) { final String[] lines = lineStream.toArray(String[] :: new); System.out.println(Arrays.toString(lines)); } catch (Exception e) { System.out.println(e.getMessage()); } }