Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pokedex pokedex = new Pokedex();
- //String line = "";
- //Read to skip the header
- br = new BufferedReader(new FileReader(csvFile));
- //Reading from the second line
- while ((line= br.readLine())!= null)
- {
- //String[] pokemonDetails = fileRead.split(",");
- String[] pokemonDetails = line.split(cvsSplitBy);
- if(pokemonDetails.length > 0 )
- {
- //Create a temporary pokemon
- int tempNum = Integer.parseInt(pokemonDetails[0].toString());
- String tempName = pokemonDetails[1].toString();
- String tempType1 = pokemonDetails[2].toString();
- String tempType2 = pokemonDetails[3].toString();
- int tempTotal = Integer.parseInt(pokemonDetails[4].toString());
- int tempHP = Integer.parseInt(pokemonDetails[5].toString());
- int tempAttack = Integer.parseInt(pokemonDetails[6].toString());;
- int tempDefense = Integer.parseInt(pokemonDetails[7].toString());
- int tempSpecAttack = Integer.parseInt(pokemonDetails[8].toString());
- int tempSpecDefense = Integer.parseInt(pokemonDetails[9].toString());;
- int tempSpeed = Integer.parseInt(pokemonDetails[10].toString());
- int tempGeneration = Integer.parseInt(pokemonDetails[11].toString());
- String tempLegendary = pokemonDetails[12].toString();
- //Save the Pokemon details in Pokemon object
- Pokemon tempPoke = new Pokemon(tempNum,tempName, tempType1, tempType2,tempTotal,tempHP,tempAttack,tempDefense,tempSpecAttack,tempSpecDefense,
- tempSpeed,tempGeneration,tempLegendary);
- //pokemonList.add(tempPoke);
- pokedex.addPokemon(tempPoke);
- line = br.readLine();
- }
- }
- br.close();
- System.out.println("############ POKEDEX CONTENTS ############");
- System.out.println(pokedex);
- }
- catch(Exception ee)
- {
- ee.printStackTrace();
- }
- {
- try
- {
- br.close();
- }
- catch(IOException ie)
- {
- System.out.println("Error occured while closing the BufferedReader");
- ie.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment