Advertisement
Guest User

Untitled

a guest
May 24th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public void readData(){
  2. // Initialise the array (size should be at least 2000)
  3. int[] data = new int[2000];
  4. File file = new File(FileChooser.open("Choose file to be read"));
  5. // read the data from the file into the array
  6. try {
  7. count = 0;
  8. Scanner scan = new Scanner(file);
  9. while (scan.hasNextInt()){
  10. int currentNum = scan.nextInt();
  11. this.data[count++] = currentNum;
  12. }
  13. }
  14.  
  15. catch(IOException e){
  16. JOptionPane.showMessageDialog(this.frame, "File loading failed: "+e);
  17. }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement