forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathByteRead.java
More file actions
42 lines (34 loc) · 919 Bytes
/
ByteRead.java
File metadata and controls
42 lines (34 loc) · 919 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
31
32
33
34
35
36
37
38
39
40
41
42
package file;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class ByteRead {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
File f = new File("D:/DEEP/third.txt");
FileOutputStream fo = new FileOutputStream(f);
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){
fo.write(i);
}
}
fo.close();
FileInputStream fi = new FileInputStream(f);
int a;
while((a = fi.read()) != -1){
System.out.println(a + " ");
}
fi.close();
}
}