-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnd-Of-File.java
More file actions
32 lines (29 loc) · 825 Bytes
/
End-Of-File.java
File metadata and controls
32 lines (29 loc) · 825 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
/*Read some unknown lines of user until you reach EOF;
each line of input contains a non-empty String.
For each line, print the line number, followed by a single space,
and then the line content received as input.*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
String s;
Scanner scan = new Scanner(System.in);
int i=1;
while(true)
{
// if no more data can be read , break
if(scan.hasNextLine()== false)
break;
//if more data can be read, scan and print
else
{
s = scan.nextLine();
System.out.println(i+" "+s);
i++;
}
}
}
}