Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Scores extends JPanel {
- public static void main(String[] args){
- ArrayList<String> scores = new ArrayList<>();
- ArrayList<Integer> highScores = new ArrayList<>();
- // try{
- // Scanner fileScanner = new Scanner(new File("C:\\Users\\Jasiul\\Documents\\GitHub\\spaceinvaders\\SpaceInvaders\\src\\spacescores\\scores.txt"));
- // while (fileScanner.hasNextInt()){
- // scores.add(fileScanner.nextInt());
- // for(Integer model : scores) {
- // String s = Integer.toString(model);
- // System.out.println("duap" + s + "\n");
- // }
- // System.out.println("line" + scores + "\n");
- // }
- // }
- // catch (Exception e){
- // System.out.println("error" + e.toString());
- // }
- //highScores.sort();
- String string = "";
- String file = "highscores.txt";
- //String file2 = "out.txt";
- // Reading
- try{
- InputStream ips = new FileInputStream(file);
- InputStreamReader ipsr = new InputStreamReader(ips);
- BufferedReader br = new BufferedReader(ipsr);
- String line;
- while ((line = br.readLine()) != null){
- System.out.println("line" + line + "\n");
- //scores.add(line);
- string += line + "\n";
- }
- br.close();
- }
- catch (Exception e){
- System.out.println(e.toString());
- }
- // Writing
- try {
- FileWriter fw = new FileWriter (file);
- BufferedWriter bw = new BufferedWriter (fw);
- PrintWriter fileOut = new PrintWriter (bw);
- fileOut.println (string+"\n test of read and write !!");
- fileOut.close();
- System.out.println("the file " + file + " is created!");
- }
- catch (Exception e){
- System.out.println(e.toString());
- }
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement