Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public static double[][] dataOnArray(String fileName){
  2. writeFile file = new writeFile();
  3. double[][] data = new double[7][];
  4. x = 0;
  5. y = 0;
  6.  
  7. try {
  8. fileScanner = new Scanner(new File(fileName));
  9. } catch (Exception e) {
  10. System.out.println(e.getMessage());
  11. }
  12. try{
  13. int i = 0;
  14. while (fileScanner.hasNextLine()) {
  15.  
  16. i = 0;
  17. String line = fileScanner.nextLine();
  18. Scanner lineScann = fileScanner = new Scanner(line);
  19. String[] splited = line.split(" ");
  20.  
  21. for(int j = 0 ; j < splited.length; j++){
  22. data[i][j] = Double.parseDouble(splited[j]);
  23. }
  24.  
  25. i++;
  26. }
  27. }
  28. catch (Exception e){
  29. System.out.println("error => " + e.getMessage());
  30. }
  31. fileScanner.close();
  32.  
  33. return data;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement