My program is fine as far as i understand it, but since it doesnt validate i wanna test it. Unfortunatly I dont know how to change the args[0], and testing ends in an ArrayIndexOutOfBoundsException...
package de.codegym.task.task18.task1817;
/*
Leerzeichen
*/
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class Solution {
public static void main(String[] args) throws IOException {
String d = args[0];
FileInputStream filo = new FileInputStream(d);
long all = 0;
long leer = 0;
while(filo.available()>0){
int i = filo.read();
all++;
if(i==32)leer++;
}
filo.close();
double v = leer/(all*1.0);
double hv = v*100.0;
double hround = Math.round(hv);
double ergebnis = hround/100.0;
System.out.println(ergebnis);
}
}