so im relatively new to code,particularly to this io problems, here is my code
actually all im trying to do is just to read a file,and add each line to my existing list that named scorelist,but the problem is i dont know where to store the files because i just dropped my files on my project folders where this score.java located, is that any problem?or am i missed something from my code?
any help will be appreciated thanks!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.util.List; import java.util.ArrayList; import java.util.Collections; import java.io.*; /** * Write a description of class Score here. * * @author (your name) * @version (a version number or a date) */ public class Score extends Actor { int t = 0; int minute,second; int currentscore,highscore,savedscore; String TotalScore,csaved; boolean countstart = false; GreenfootImage score; List <Integer> scorelist = new ArrayList<Integer>(); private void readfile() { BufferedReader br = null; try { br = new BufferedReader(new FileReader("highscore.txt")); String r = br.readLine(); while(r != null) { scorelist.add(Integer.parseInt(r)); } } catch (IOException ex) { ex.printStackTrace();} } }