Guest User

Untitled

a guest
Nov 20th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. while(read.hasNextLine())
  2. {
  3. line = read.nextLine();
  4. String[] words = line.split("-");
  5. if(words.length == 5)
  6. {
  7. Title[counter] = words[0].matches("\s+") ? "No Title" : words[0];
  8. Author[counter] = words[1].matches("\s+") ? "No Author" : words[1];
  9. Price[counter] = !words[2].matches("\d+") ? 0 : Integer.parseInt(words[2]);
  10. Publisher[counter] = words[3].matches("\s+") ? "No Publisher" : words[3];
  11. ISBN[counter] = !words[4].matches("\d+") ? 0 : Integer.parseInt(words[4]);
  12. System.out.println(Title[counter] + Author[counter] + Price[counter] + Publisher[counter] + ISBN[counter]);
  13. counter++;
  14. }
  15. else
  16. {
  17. System.out.println("Invalid Data format: " + line);
  18. }
  19. }
Add Comment
Please, Sign In to add comment