import java.io.FileInputStream; class TailleSansEspaces { public static void main(String[] args) { try { FileInputStream f= new FileInputStream(args[0]); byte[] buffer= new byte[102400]; int aux, taille= 0; while( (aux= f.read(buffer, 0, 102400)) > 0 ) { int j, i= 0; String s= new String(buffer, 0, aux); for(; (j= s.indexOf(' ', i)) >= 0; i= j + 1) taille+= j - i; taille+= s.length() - i; } System.out.println("" + taille); } catch(Throwable eThrow) { eThrow.printStackTrace(); } } }