Forums Register Login
How to input data using BufferedReader and save as an external XML file?
How to create code which will be perform next actions?
• input data from the console
• create own type of data
• saving data in an array
• display on the screen
• saving to an external XML file

Java console input -> Example:

System.out.println ("Enter quantity of cars") // how many cars we will input
-> 1
(it means we have 1 car, which we will describe bellow, but may be more)

System.out.println("Enter car brand")
-> Ford

System.out.println("Enter color")
-> Red

System.out.println("Enter type")
-> Sedan

Then program will be save data as external XML file (C:\\cars.xml) (<1><brand>Ford</brand><color>Red</color><type>Sedan</type></1>)

In this task i need to use BufferedReader, Exceptions, Array, XML convert..

Welcome to thr Ranch

I wouldn't use a buffered reader for keyboard input, since Scanner was introduced 11 years ago. You can print a request and get the data from the keyboard in the appropriate format. Get that working and get the data into a Car class. Then consider writing the XML later.
I think your XML would look more like this:

I would have a Car class that has a String toXML() method. And perhaps a Cars class that manages a list of Cars; also with a String toXML() method. Cars.toXML() will be responsible for iterating through the list and calling the Car.toXML() method on each one.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 215 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 16, 2018 14:14:39.