Created
January 26, 2017 08:46
-
-
Save HelloThisIsFlo/5d6f7d398ddb32774080ea4df41b5ef4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeClass { | |
public List<Book> findSpecificBookInFile(String bookName, String filePath) { | |
///////////////////////////// | |
// Parsing the XML file /// | |
///////////////////////////// | |
ParseType xmlType = new ParseType(Parsing.Type.XML, Parsing.Xml.ExtraColumn); | |
ParseFileFactory xmlFileFactory = new ParseFileFactory(xmlType); | |
ParseFile<Parsing.Type.XML> xmlFile = xmlFileFactory.open(filePath); | |
RootType bookType = new TypeToken<Book>() {}.getType(); | |
List<Book> fromFile; | |
try { | |
fromFile = xmlFile.parseList(bookType, 0); | |
} catch (IOException e) { | |
// do things | |
} | |
///////////////// | |
// Find book /// | |
///////////////// | |
return fromFile.stream() | |
.filter(book -> bookName.equals(book.title())) | |
.findFirst() | |
.orElse(Book.NULL); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment