File in a static block

  • 8
  • Locked
Initialize the variable Statics.FILE_NAME to the full path to a data file that contains several lines. Then, in the static block, read all the lines from the file named Statics.FILE_NAME, and add them separately to the List lines.
You can't complete this task, because you're not signed in.
Comments (8)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 29 , Poland, Poland
19 April, 06:26
Can I use in this task List<String> readAllLines(Path path) method or veryfication won't work for this solution? Or is it bad idea to use this methods at all in this task?
Alex Tor
Level 26 , Bulgaria
20 May, 11:21
it's probably too late for the answer, but I believe some methods don't work because of Java 8 limitations.
Level 24 , Wittenberg, Germany
4 June 2021, 21:11
task1525 (File in a static block) caveat: keep it simple and use a fixed filename like "c:/Windows/win.ini", which worked for me. Farting around with System.getenv, Paths and so on in order to use the moral equivalent of "%windir%/win.ini" and "%JAVA_HOME%/COPYRIGHT" worked only when testing (i.e. running the Solution class) but failed during verification because then the files were not found. No idea why ...
Kent Hervey Software Engineer/Consult at Zeal IT ConsultantsExpert
16 April 2021, 22:59
This task has the lowest number of "completed by <<>> students of any task I have encountered so far. That may change tomorrow as maybe lots of people will decide to do this one, but it perplexes me, it is a good task and certainly possible.
9 August 2020, 21:56
Static section for file reading is expected in Solution class.
Thomas Sixberry
Level 16 , Rochester Hills, United States
15 February 2020, 17:48
What does "to the full path to a data file" mean? ٩(´•⌢•` )۶⁼³₌₃
Roman Grygorczuk
Level 19 , Cracow, Poland
30 December 2020, 13:07
For instance "C:/Users/USER_NAME/Documents/CodeGymTasks/2.JavaCore/src/com/codegym/task/task15/task1525/test.txt"
Level 18 , Korampallam, India
9 July 2019, 06:32
what should i put for file path