-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackerRank190820.java
More file actions
92 lines (78 loc) · 2.65 KB
/
HackerRank190820.java
File metadata and controls
92 lines (78 loc) · 2.65 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @author Divyam (https://github.com/DevYam)
* @created 19/08/2020 - 10:18
* @project java
*/
public class HackerRank190820 {
public static void main(String[] args) throws IOException {
/**
* ways to take input from console in java - GFG
*/
// Reading from console
/*
System.out.println("Enter a multiline text");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = bufferedReader.readLine())!=null){
System.out.println(line);
}
*/
// Reading form file
/*
System.out.println("Enter a multiline text");
BufferedReader bufferedReader = new BufferedReader(new FileReader("C:\\Users\\I516379\\IdeaProjects\\java\\src\\read.txt"));
String line;
while ((line = bufferedReader.readLine())!=null){
System.out.println(line);
}
*/
/**
* Question -
* The challenge here is to read lines of input until you reach EOF, then number and print all lines of content.
*
* Hint: Java's Scanner.hasNext() method is helpful for this problem.
*
* Input Format
*
* Read some unknown lines of input from stdin(System.in) until you reach EOF; each line of input contains a non-empty String.
*
* Output Format
*
* For each line, print the line number, followed by a single space, and then the line content received as input.
*
* Sample Input
*
* Hello world
* I am a file
* Read me until end-of-file.
* Sample Output
*
* 1 Hello world
* 2 I am a file
* 3 Read me until end-of-file
*
*/
// Sol -
// import java.io.*;
// import java.util.*;
//
// public class Solution {
//
// public static void main(String[] args) throws IOException {
// /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// String line;
// int l=1;
// while((line = br.readLine())!=null){
// String num = Integer.toString(l);
// System.out.println(num+" "+line);
// l = l+1;
// }
// }
// }
}
}