-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCh17Q0203.java
More file actions
executable file
·58 lines (55 loc) · 1.2 KB
/
Ch17Q0203.java
File metadata and controls
executable file
·58 lines (55 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* */ package ch17;
/* */ import java.io.*;
/* */
/* */
/* */
/* */ public class Ch17Q0203 {
/* */ public static void main(String[] args) {
/* 8 */ File f = new File("ex17.dat");
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* 35 */ long sum = 0L;
/* 36 */ int counter = 0;
/* */
/* 38 */ try(FileInputStream fis = new FileInputStream(f);
/* 39 */ DataInputStream dis = new DataInputStream(fis)) {
/* */
/* 41 */ while (dis.available() != 0) {
/* 42 */ sum += dis.readInt();
/* 43 */ counter++;
/* */ }
/* 45 */ } catch (IOException ioe) {
/* 46 */ ioe.printStackTrace();
/* */ }
/* 48 */ System.out.println("numbers sum: " + sum);
/* 49 */ System.out.println("numbers read: " + counter);
/* */ }
/* */ }
/* Location: /Volumes/TXS.128G/hope useful/practice/2020.jar!/ch17/Ch17Q0203.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/