Guest User

Untitled

a guest
May 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. int i,n;
  2. Foglalas[] foglalasok;
  3. String[] temp;
  4. String delimiter = " ";
  5.  
  6. try {
  7. olvas = new BufferedReader(new FileReader(pitypang));
  8. String be;
  9. n = Integer.parseInt(olvas.readLine());
  10. foglalasok = new Foglalas[n];
  11. for (i=0; i<n; i++) {
  12. foglalasok[i] = new Foglalas();
  13. }
  14. i=0;
  15. while ((be = olvas.readLine()) != null) {
  16. //szoveg.append(be).append(System.getProperty("line.separator"));
  17. temp=be.split(delimiter);
  18. foglalasok[i].sorszam = Integer.parseInt(temp[0]);
  19. foglalasok[i].szoba = Integer.parseInt(temp[1]);
  20. foglalasok[i].erk = Integer.parseInt(temp[2]);
  21. foglalasok[i].tav = Integer.parseInt(temp[3]);
  22. foglalasok[i].vendeg = Integer.parseInt(temp[4]);
  23. foglalasok[i].reggeli = Boolean.parseBoolean(temp[5]);
  24. foglalasok[i].nev = temp[6];
  25. i++;
  26. }
  27. }
  28. catch (FileNotFoundException e) {
  29. e.printStackTrace();
  30. }
  31. catch (IOException e) {
  32. e.printStackTrace();
  33. }
  34. finally {
  35. try {
  36. if (olvas != null) {olvas.close();}
  37. }
  38. catch (IOException e) {
  39. e.printStackTrace();
  40. }
  41. }
  42.  
  43. //LEGHOSSZABB TARTÓZKODÁS
  44. int[] tartam = new int[n]; <----- variable n might not have been initialized
Add Comment
Please, Sign In to add comment