-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntering.java
More file actions
90 lines (68 loc) · 2.59 KB
/
Copy pathEntering.java
File metadata and controls
90 lines (68 loc) · 2.59 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
package Collections;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
/**
* как мы считываем байты. Допустим считали в Reader,
* как вывести?
*
* */
public class Entering {
public static Map<String, Long> getSalesMap(Reader reader) {
BufferedReader read = new BufferedReader(reader);
Map<String, Long> map = new HashMap<>();
String Line = null;
String text = null;
while(true) {
try {
if ((Line = read.readLine()) == null) break;
} catch (IOException e) {
e.printStackTrace();
}
String name = Line.trim().split(" ")[0];
Long salary = Long.parseLong((Line.trim().split(" ")[1]));
map.put(name, salary);
}
return map;
}
//Line = reader.readLine();
Map<String, Long> map = new HashMap<>();
/*while((Line = reader.readLine()) != null) {
String name = Line.trim().split(" ")[0];
Integer salary = Integer.parseInt(Line.trim().split(" ")[1]);
map.put(name, salary);
}
*/
/* BufferedReader read = (BufferedReader) Reader;
String Line;
// ниже вывод на экран входящего буфера (потока)
while (read.ready()) {
Line = read.readLine();
System.out.println(Line);
}
while((Line = read.readLine()) != null) {
String name = Line.trim().split(" ")[0];
Integer salary = Integer.parseInt(Line.trim().split(" ")[1]);
map.put(name, salary);
}
*/
// System.out.println(map.get("Алексей"));
// System.out.println(map.get("Алексй"));
public static void main(String[] args) throws IOException {
ByteArrayInputStream bais = new ByteArrayInputStream(("Алексей 3000" +
"\nДмитрий 9000\nАнтон 3000\nАлексей 7000\nАнтон 8000").getBytes());
BufferedReader buffReader = new BufferedReader(new InputStreamReader(bais));
getSalesMap(buffReader);
/*
Reader reader = new FileReader("test.txt");
for (Collections.Map.Entry<String, Integer> entry : getSalesMap(reader).entrySet()) {
System.out.println(entry);
} */
// int d = reader.read();
//boolean b = reader.ready();
// System.out.println(b);
/*for (Collections.Map.Entry<String, Integer> entry : getSalesMap(reader).entrySet()) {
System.out.println(entry);
}*/
}
}