多年不找工作,刷题的第一个作业

import java.io.IOException;
import java.io.InputStream;

public class Main {

public static void main(String[] args) throws IOException {
    int count = 0;
    InputStream inputStream = System.in;
    char c = (char) inputStream.read();

    while (c != '\n') {

        if (count == ' ') {
            count = 0;
        } else {
            count++;
        }
        c = (char) inputStream.read();
    }

    System.out.println(count);

}

}