Now you need to write something to a file. You need to first read the file name from the console, then read lines entered by the user until the user enters "exit". Finally, write all the entered lines to the file, each on a new line.
Writing to a file from the console
- 16
Locked
Comments (19)
- Popular
- New
- Old
You must be signed in to leave a comment
Hoist
5 March, 03:58
HELP has good discussions already going -- jump into one
right HERE: https://codegym.cc/help/5068
0
Vadim “迪姆哥”
28 November 2022, 18:25
I think that that line:
"Program must absolutely write all of the entered lines (includes "exit") to the file, each on a new line"
Isn't clear about requirenment, which is: user must store all lines in buffer, then after it receive "exit" line in console, write all contents stored in buffer with "exit" line to the file.
+1
Hiyo Full Stack Developer
3 February, 02:44
It's pretty clear to me.
Read each line from console and write to file. It's a loop, if the current line happens to be "exit", write it to file and break out of the loop. That's all.
Maybe you used a different method, I'm not sure but this was what I understood from the requirement.
+1
Justin Smith
2 August 2021, 18:20
This looked scary, but I got it on my first try!
One of the really helpful things about IDEA is that, when you have your BufferedWriter object, you can then type the name of the object plus a period and it will show you all the methods you might want to use. For this task, that helped a lot with figuring out how to write the data to the file and tell it to go to the next line of the file.
+1
Hoist
5 March, 03:42
THX I am using the CG IDE way too much
0
Bartlomiej Drozd
22 January 2021, 17:55
For those with condition 5 error; I forgot I had hardcoded my file path. This could be one of the reasons this condition fails (I had it all running ages ago...:)
0
Kent Hervey Software Engineer/Consult at Zeal IT ConsultantsExpert
31 December 2020, 23:15
Have not started coding yet. the summary into says to write to the console, but the requirements say don't
I will start with the latter
0
LennyMan
27 December 2020, 14:07
It was hard, i definetely needed to check the Help section, but man, finally we start to code something real! 😋
0
Roman Grygorczuk
19 November 2020, 21:33
Admin, I believe that there might be some issues with the tests. I have passed this exercise but I was not able to see the provided in console text in the file.
0
MoJo
15 October 2020, 09:50
tip: by adding + "\n" to any string you are adding a line break to it.
0
Switch/Cypher
23 September 2020, 13:06
Yeah this is hard.
+1
Petros
4 August 2020, 17:50
Brutal. Had to go straight to help to figure this one out.
+2
Hoist
5 March, 03:47
I look at so much other code to kick-off ideas. It's already written and in the wild to use and even improve it. Look at StackO / Reddit / Chat GPT / Googs / YouTube / GitHub / Codegym Articles / CG Chat all that --- so many cool and different implementations to ponder over ...
0