Guest User

Untitled

a guest
Jan 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. Pokedex pokedex = new Pokedex();
  2. //String line = "";
  3. //Read to skip the header
  4. br = new BufferedReader(new FileReader(csvFile));
  5. //Reading from the second line
  6. while ((line= br.readLine())!= null)
  7. {
  8. //String[] pokemonDetails = fileRead.split(",");
  9. String[] pokemonDetails = line.split(cvsSplitBy);
  10.  
  11. if(pokemonDetails.length > 0 )
  12. {
  13.  
  14.  
  15.  
  16. //Create a temporary pokemon
  17. int tempNum = Integer.parseInt(pokemonDetails[0].toString());
  18. String tempName = pokemonDetails[1].toString();
  19. String tempType1 = pokemonDetails[2].toString();
  20. String tempType2 = pokemonDetails[3].toString();
  21. int tempTotal = Integer.parseInt(pokemonDetails[4].toString());
  22. int tempHP = Integer.parseInt(pokemonDetails[5].toString());
  23. int tempAttack = Integer.parseInt(pokemonDetails[6].toString());;
  24. int tempDefense = Integer.parseInt(pokemonDetails[7].toString());
  25. int tempSpecAttack = Integer.parseInt(pokemonDetails[8].toString());
  26. int tempSpecDefense = Integer.parseInt(pokemonDetails[9].toString());;
  27. int tempSpeed = Integer.parseInt(pokemonDetails[10].toString());
  28. int tempGeneration = Integer.parseInt(pokemonDetails[11].toString());
  29. String tempLegendary = pokemonDetails[12].toString();
  30. //Save the Pokemon details in Pokemon object
  31. Pokemon tempPoke = new Pokemon(tempNum,tempName, tempType1, tempType2,tempTotal,tempHP,tempAttack,tempDefense,tempSpecAttack,tempSpecDefense,
  32. tempSpeed,tempGeneration,tempLegendary);
  33. //pokemonList.add(tempPoke);
  34. pokedex.addPokemon(tempPoke);
  35. line = br.readLine();
  36.  
  37. }
  38.  
  39. }
  40. br.close();
  41. System.out.println("############ POKEDEX CONTENTS ############");
  42. System.out.println(pokedex);
  43. }
  44. catch(Exception ee)
  45. {
  46. ee.printStackTrace();
  47. }
  48.  
  49.  
  50.  
  51.  
  52. {
  53. try
  54. {
  55. br.close();
  56. }
  57. catch(IOException ie)
  58. {
  59. System.out.println("Error occured while closing the BufferedReader");
  60. ie.printStackTrace();
  61. }
  62.  
  63. }
  64.  
  65.  
  66. }
Add Comment
Please, Sign In to add comment