//Aim : Program for printing text file in parts
import java.io.*;
import java.util.*;
class TestPart
{
public static void main(String[] a)
{
try
{
FileReader f=new FileReader("PrintPart.txt");
BufferedReader b=new BufferedReader(f);
String s;
s=" ";
L:
while(s!=null )
{
for(int i=0;i<5;i++)
{
s=b.readLine();
if(s==null)
break L;
System.out.println(s);
}
System.out.println("Press Enter Key To Continue.......");
if(System.in.read()==13 && System.in.read()==10)
continue;
else
break L;
}
}
catch(Exception e)
{
System.out.println("Error!");
}
}
}
Output :
E:\MyJava>javac TestPart.java
E:\MyJava>java TestPart
1
2
3
4
5
Press Enter Key To Continue.......
6
7
8
9
10
Press Enter Key To Continue.......
11
12
13
14
15
Press Enter Key To Continue.......
16
17
18
19
20
Press Enter Key To Continue.......
21
22
23
24
25
Press Enter Key To Continue.......
26
27
28
29
30
Press Enter Key To Continue.......
31
32
33
34
35
Press Enter Key To Continue.......
36
37
38
39
40
Press Enter Key To Continue.......
41
42
43
44
45
Press Enter Key To Continue.......
46
47
48
49
50
Press Enter Key To Continue.......
E:\MyJava>
import java.io.*;
import java.util.*;
class TestPart
{
public static void main(String[] a)
{
try
{
FileReader f=new FileReader("PrintPart.txt");
BufferedReader b=new BufferedReader(f);
String s;
s=" ";
L:
while(s!=null )
{
for(int i=0;i<5;i++)
{
s=b.readLine();
if(s==null)
break L;
System.out.println(s);
}
System.out.println("Press Enter Key To Continue.......");
if(System.in.read()==13 && System.in.read()==10)
continue;
else
break L;
}
}
catch(Exception e)
{
System.out.println("Error!");
}
}
}
Output :
E:\MyJava>javac TestPart.java
E:\MyJava>java TestPart
1
2
3
4
5
Press Enter Key To Continue.......
6
7
8
9
10
Press Enter Key To Continue.......
11
12
13
14
15
Press Enter Key To Continue.......
16
17
18
19
20
Press Enter Key To Continue.......
21
22
23
24
25
Press Enter Key To Continue.......
26
27
28
29
30
Press Enter Key To Continue.......
31
32
33
34
35
Press Enter Key To Continue.......
36
37
38
39
40
Press Enter Key To Continue.......
41
42
43
44
45
Press Enter Key To Continue.......
46
47
48
49
50
Press Enter Key To Continue.......
E:\MyJava>
No comments:
Post a Comment