Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int[] Soubor(String soubor) {
- //try catch na errory
- try {
- //udelam objekt file, coz je muj soubor z parametru
- File file = new File(soubor);
- //scanner pro soubor
- Scanner s = new Scanner(file);
- int x = 0;
- //pokud je na dalsi pozici cislo, zvetsi pocitalo velikosti rady
- while (s.hasNext()) {
- x++;
- s.nextInt();
- }
- s.close();
- int[] rada = new int[x];
- Scanner r = new Scanner(file);
- for(int i = 0;i<rada.length;i++) {
- rada[i] = r.nextInt();
- }
- r.close();
- return rada;
- } catch (FileNotFoundException e) {
- return null;
- // TODO Auto-generated catch block
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement