Finding data inside a file

  • 20
Read a file name from the console. Search the file for information related to the specified id. Display it in the format used in the file. The program is started with one argument: id (an int). Close the streams. The file data is separated by spaces and stored in the following order: id productName
You can't complete this task, because you're not signed in.
Comments (9)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Adrian Level 20, Spanish Town, Jamaica
22 August 2020, 04:33
I had a good laugh at myself! what i did for this was absolutely insane, i thought i had to get and parse the values (int, string double ) this led me down quite the road! i learnt a ton! and then, it suddenly dawned on me that all this task required was checking the id value and printing the line. enormously more simple than i ended up doing!
MoJo Level 20, Cairns, Australia
11 December 2020, 12:29
Same here lol. I think the task conditions are poorly worded. Maybe an intput and an output example would help.
Liliane Top Level 20, Amsterdam, Netherlands
8 January, 12:11
"The program should search the file and display information related to the specified id passed as the first argument." This is very hard to understand if English is not your native tongue. I also went way down the rabbit hole ... haha
Petros Level 23, Columbia, United States
22 August 2020, 04:01
I brushed over where it said "productName is a String — it can contain spaces". That messed me up for a while. A good reminder to read the requirements carefully.
Artur Verdyan Level 24, Hoboken, United States
8 June 2020, 16:28
Sometimes I feel that maybe I am missing something. Is there somewhere a file which for each task which I need to use ? So far I just created it myself
Sven Level 19, Hanover, Germany
4 October 2019, 20:33
It does work with the testfile, but the verification fails anyways. Any suggestions as to what the problem is?
Roman Level 41
7 October 2019, 06:10
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at
Julián Orellana Level 20, Guayaquil, Ecuador
15 October 2018, 17:50
wich is the byte that says a separate line 10 or 13?
Roman Level 41
16 October 2018, 06:07
Try to use the universal solution :)