Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while(read.hasNextLine())
- {
- line = read.nextLine();
- String[] words = line.split("-");
- if(words.length == 5)
- {
- Title[counter] = words[0].matches("\s+") ? "No Title" : words[0];
- Author[counter] = words[1].matches("\s+") ? "No Author" : words[1];
- Price[counter] = !words[2].matches("\d+") ? 0 : Integer.parseInt(words[2]);
- Publisher[counter] = words[3].matches("\s+") ? "No Publisher" : words[3];
- ISBN[counter] = !words[4].matches("\d+") ? 0 : Integer.parseInt(words[4]);
- System.out.println(Title[counter] + Author[counter] + Price[counter] + Publisher[counter] + ISBN[counter]);
- counter++;
- }
- else
- {
- System.out.println("Invalid Data format: " + line);
- }
- }
Add Comment
Please, Sign In to add comment