(String[] args)
| 14 | |
| 15 | public class wc { |
| 16 | public static void main(String[] args) { |
| 17 | int nl = 0, nw = 0, nc = 0; |
| 18 | |
| 19 | try { |
| 20 | byte[] buff = new byte[4096]; |
| 21 | boolean inword = false; |
| 22 | int length; |
| 23 | char c; |
| 24 | |
| 25 | while ((length = System.in.read(buff)) != -1) { |
| 26 | nc += length; |
| 27 | for(int i = 0; i < length; i++) { |
| 28 | c = (char)buff[i]; |
| 29 | if (c == '\n') |
| 30 | ++nl; |
| 31 | if (Character.isWhitespace(c)) |
| 32 | inword = false; |
| 33 | else if (inword == false) { |
| 34 | ++nw; |
| 35 | inword = true; |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | } catch (IOException e) { |
| 40 | System.err.println(e); |
| 41 | return; |
| 42 | } |
| 43 | System.out.println(Integer.toString(nl) + " " + |
| 44 | Integer.toString(nw) + " " + |
| 45 | Integer.toString(nc)); |
| 46 | } |
| 47 | } |
nothing calls this directly
no test coverage detected