Can't work out how to read object from .txt file
I need a method that will be able to load the following from a text file and turn them into Book objects:
Northern Lights:Philip Pullman:fantasy:1998
City of Lost Souls:Cassandra Clare:fantasy:2012
Robinson Crusoe:Daniel Defoe:adventure:1719
The book object has the parameters - String title - String author - String genre - int year(in that order). I can read and save if the title, author and genre are one word each, but I can't work out how to read them if the Strings contain spaces, let alone read the file separating each parameter with the ":".
Can anyone at least let me know which API I should be using to read objects saved in this format.
An example method would be amazing, but I understand if that's too lazy of me. I'm new to this forum.
Re: Can't work out how to read object from .txt file
Have you read about the String class? What about the Scanner class?
There are ways to split a string up at a specified string or character. See what some reading can find.