There is written code that searches for files in a particular folder by a mask and, if it finds them, displays a list of these files. Output standard in the console. I would like to make the work of the program more convenient: 1. Create a graphic window with one button, which, if pressed, would display this list of files in a special field in the same window. How to do it? 2. List the files in the * .txt file. How to implement it?

That is, all that is displayed in the console as a result of code execution - how can all this be moved to a graphic window or to a txt file?

  • one
    you can simply redirect the standard output to a file: команда_запуска_вашей_программы всякие параметры > file.txt - zRrr

2 answers 2

For the first one, I would recommend JavaFX (I’m working with it myself now) and for the second I’ll read something like

  • Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky

Thank you. I figured it out. It was necessary to add just a few lines to the main-class (at the beginning of the file, when declaring variables):

 PrintStream out = null; try { out = new PrintStream(new FileOutputStream("output.txt")); } catch (FileNotFoundException e) { e.printStackTrace(); } System.setOut(out);