-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.java
More file actions
68 lines (67 loc) · 1.25 KB
/
Input.java
File metadata and controls
68 lines (67 loc) · 1.25 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
package code.google;
import java.io.*;
import java.util.*;
public class Input
{
BufferedReader reader;
LinkedList<String> strings;
public Input(String filename) throws IOException
{
reader=new BufferedReader(new FileReader(filename));
strings=new LinkedList<String>();
}
public Input()
{
reader=new BufferedReader(new InputStreamReader(System.in));
strings=new LinkedList<String>();
}
public void close() throws IOException
{
reader.close();
}
void check() throws IOException
{
while(strings.size()==0)
{
String s=reader.readLine();
String[] ss=s.split(" ");
for(int i=0;i<ss.length;i++)
{
strings.addLast(ss[i]);
}
}
while(strings.getFirst().length()==0)
{
strings.removeFirst();
}
}
public String readString() throws IOException
{
check();
//System.out.println(strings.getFirst());
return strings.removeFirst();
}
public int readInt() throws IOException
{
return Integer.parseInt(readString());
}
public double readDouble() throws IOException
{
return Double.parseDouble(readString());
}
public String readLine() throws IOException
{
check();
String r="";
while(strings.size()>0)
{
r+=(strings.removeFirst());
if(strings.size()==0)
{
break;
}
r+=" ";
}
return r;
}
}