- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopyPrime.java
More file actions
Latest commit
30 lines (26 loc) · 812 Bytes
/
Copy pathCopyPrime.java
File metadata and controls
30 lines (26 loc) · 812 Bytes
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
packagep2;
importjava.io.*;
importjava.util.*;
importp1.*;
classCopyPrime {
publicstaticvoidmain(Stringargs[]) {
try {
intn;
FileReaderfin = newFileReader("input.txt");
Scannerfscan = newScanner(fin);
FileWriterfout = newFileWriter("output.txt");
while (fscan.hasNextInt() == true) {
n = fscan.nextInt();
if (check.prime(n) == 1) {
System.out.println("Prime");
fout.write(Integer.toString(n) + "\n");
}
}
fscan.close();
fin.close();
fout.close();
} catch (IOExceptione) {
System.out.println("Caught Exception:" + e);
}
}
}