I have the following thing to do :
-read data from file.txt And then parse it to our object.
-For example I have the folllowing ferrari.txt
- and inside I have
Car{mark='ferrari', model='sf90', productionYear=2020, hp=1000}
now I should parse this to the ObjectCar
But all over what I could find on google is not looking like what I should use
(maybe I search wrong)
Is someone here that can give me a good link that I can get the correct info?
>Solution :
You cannot "parse" that format. You could do that if you serialized the Car Object in a binary file. But since you are using a plain text file, something like this would not be possible. The format is also not a well-known one (such as JSON). If it were one of the well-known formats, you could use one of the many available libraries out there to do it for you. You could try to map the fields, but that is not that straightforward.
My suggestion is to change the format to JSON. It is human understandable, quick to work with and there is a variety of libraries supporting it.