Code below:
package com.codegym.task.task18.task1817;
/*
Spaces
*/
import java.io.FileInputStream;
import java.io.IOException;
public class Solution {
public static void main(String[] args) {
int n1 = 0;
int n2 = 0;
try (FileInputStream fis = new FileInputStream(args[0])){
while (fis.available() > 0){
int data = fis.read();
if(data == 32){
n2++;
}else{
n1++;
}
}
}catch (IOException ioe){
}
double d = Math.round((n2/(double)n1*100)*100)/100d;
System.out.println(d);
}
}