forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataip_Op.java
More file actions
43 lines (38 loc) · 1.03 KB
/
Dataip_Op.java
File metadata and controls
43 lines (38 loc) · 1.03 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
package file;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
public class Dataip_Op {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
File f = new File("D:/DEEP/seven.txt");
FileOutputStream fo = new FileOutputStream(f);
DataOutputStream d = new DataOutputStream(fo);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter number for range : ");
int n = Integer.parseInt(br.readLine());
System.out.println("<< Even Number >>");
for (int i = 1; i < n ; i++ ) {
if(i % 2 == 0){
d.write(i);
}
}
d.flush();
d.close();
FileInputStream fi = new FileInputStream(f);
DataInputStream di = new DataInputStream(fi);
int a;
while((a = di.read()) != -1){
System.out.println(a + " ");
}
di.close();
}
}