-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile5.java
More file actions
49 lines (34 loc) · 958 Bytes
/
Copy pathfile5.java
File metadata and controls
49 lines (34 loc) · 958 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
43
44
45
46
47
48
49
//to read from text file line by line
import java.io.*;
import java.lang.*;
import java.util.*;
class file5
{
public static void main(String arg[]) throws Exception
{
FileReader fobj=new FileReader("file5.java");
//wrap reader by Scanner object
Scanner sobj=new Scanner(fobj);
while(sobj.hasNext()) //check the next word
{
String line=sobj.nextLine();
System.out.println(line);
}
}
}
/*
import java.io.*;
import java.lang.*;
import java.util.*;
class file5
{
public static void main(String arg[]) throws Exception
{
FileReader fobj=new FileReader("file5.java");
//wrap reader by BufferedReader object
BufferedReader bobj=new BufferedReader(fobj);
int ch=bobj.read(); //read single character
String line=bobj.readLine(); //read line
}
}
*/