You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
String data = socketReader.readStr(); // Read first string
25
+
String data = socketReader.nextStr(); // Read first string
26
26
27
27
```
28
28
@@ -65,53 +65,53 @@ public class InputReaderUsageExample {
65
65
66
66
**ALL methods in the InputReader class must be caught or thrown** because they throw an java.io.IOException when something bad happens such as trying to read a byte value from an empty stream. See [here](https://github.com/williamfiset/FastJavaIO#examples) for detailed examples of how to use the methods outlined below.
67
67
68
-
### .byteInt()
68
+
### .nextByte()
69
69
Reads a signed 8 bit integer from the input stream.
70
70
```java
71
71
InputReader in =newInputReader();
72
-
byte bytevalue = in.readByte();
72
+
byte bytevalue = in.nextByte();
73
73
```
74
74
75
-
### .readInt()
75
+
### .nextInt()
76
76
Reads a signed 32 bit integer from the input stream.
77
77
```java
78
78
InputReader in =newInputReader();
79
-
intintvalue= in.readInt();
79
+
intintValue= in.nextInt();
80
80
```
81
81
82
-
### .readLong()
82
+
### .nextLong()
83
83
Reads a signed 64 bit integer from the input stream.
84
84
```java
85
85
InputReader in =newInputReader();
86
-
long longvalue = in.readLong();
86
+
long longvalue = in.nextLong();
87
87
```
88
88
89
-
### .readDouble()
89
+
### .nextDouble()
90
90
Reads a signed double from the input stream.
91
91
```java
92
92
InputReader in =newInputReader();
93
-
double doublevalue = in.readDouble();
93
+
double doublevalue = in.nextDouble();
94
94
```
95
95
96
-
### .readFastDouble()
97
-
Reads a double value ~3x times faster from the input stream than the .readDouble() method, but at the cost of accuracy. This method can only read doubles with at most 21 digits after the decimal point. Furthermore, the value being read may have an error of at most ~5*10^-16 (obtained from empirical tests) from its true value due to finite floating point number arithmetic (adding, multiplication) used to perform the quick calculation.
96
+
### .nextDoubleFast()
97
+
Reads a double value ~3x times faster from the input stream than the .nextDouble() method, but at the cost of accuracy. This method can only read doubles with at most 21 digits after the decimal point. Furthermore, the value being read may have an error of at most ~5*10^-16 (obtained from empirical tests) from its true value due to finite floating point number arithmetic (adding, multiplication) used to perform the quick calculation.
98
98
```java
99
99
InputReader in =newInputReader();
100
-
double doublevalue = in.readDoubleFast();
100
+
double doublevalue = in.nextDoubleFast();
101
101
```
102
-
### .readStr()
102
+
### .nextStr()
103
103
Reads a string of characters from the input stream. The delimiter separating a string of characters is set to be
104
104
any ASCII value <= 32 meaning any spaces, new lines, EOF characters, tabs... all of which do not count as being part of the string. If the input stream is empty null is returned.
105
105
```java
106
106
InputReader in =newInputReader();
107
-
String str = in.readStr();
107
+
String str = in.nextStr();
108
108
```
109
109
110
-
### .readLine()
111
-
Reads a line of characters from the input stream until a new line character is reached. The .readLine() method includes spaces found in the input stream. If the input stream is empty a null value is returned to indicate so.
110
+
### .nextLine()
111
+
Reads a line of characters from the input stream until a new line character is reached. The .nextLine() method includes spaces found in the input stream. If the input stream is empty a null value is returned to indicate so.
112
112
```java
113
113
InputReader in =newInputReader();
114
-
String line = in.readLine();
114
+
String line = in.nextLine();
115
115
```
116
116
117
117
## Examples
@@ -123,94 +123,94 @@ String line = in.readLine();
123
123
" 123 3.141592 abcdef the quick brown fox\n jumps \nover\n\n the lazy dog"
124
124
125
125
InputReader in =newInputReader();
126
-
int intvalue = in.readInt(); // '123'
127
-
double dblvalue = in.readDouble(); // '3.141592'
128
-
String str = in.readStr(); // 'abcdef'
129
-
String str2 = in.readStr(); // 'the'
130
-
String line = in.readLine(); // 'quick brown fox'
131
-
String line1 = in.readLine(); // ' jumps '
132
-
String line2 = in.readLine(); // 'over'
133
-
String line3 = in.readLine(); // ''
134
-
String line4 = in.readLine(); // ' the lazy dog'
135
-
String line5 = in.readLine(); // null
136
-
```
137
-
138
-
#### .readByte() examples
126
+
int intvalue = in.nextInt(); // '123'
127
+
double dblvalue = in.nextDouble(); // '3.141592'
128
+
String str = in.nextStr(); // 'abcdef'
129
+
String str2 = in.nextStr(); // 'the'
130
+
String line = in.nextLine(); // 'quick brown fox'
131
+
String line1 = in.nextLine(); // ' jumps '
132
+
String line2 = in.nextLine(); // 'over'
133
+
String line3 = in.nextLine(); // ''
134
+
String line4 = in.nextLine(); // ' the lazy dog'
135
+
String line5 = in.nextLine(); // null
136
+
```
137
+
138
+
#### .nextByte() examples
139
139
```java
140
140
// Suppose standard input stream contains the following byte values we want to read:
141
141
"-128 127 -1 -0 0 1 3454"
142
142
// ^ NOTE: This does NOT fit in a signed byte!
143
143
144
144
InputReader in =newInputReader();
145
-
byte b1 = in.readByte(); // -128
146
-
byte b2 = in.readByte(); // 127
147
-
byte b3 = in.readByte(); // -1
148
-
byte b4 = in.readByte(); // 0
149
-
byte b5 = in.readByte(); // 0
150
-
byte b6 = in.readByte(); // 1
151
-
byte b7 = in.readByte(); // 126, this byte value overflowed! No safety check
145
+
byte b1 = in.nextByte(); // -128
146
+
byte b2 = in.nextByte(); // 127
147
+
byte b3 = in.nextByte(); // -1
148
+
byte b4 = in.nextByte(); // 0
149
+
byte b5 = in.nextByte(); // 0
150
+
byte b6 = in.nextByte(); // 1
151
+
byte b7 = in.nextByte(); // 126, this byte value overflowed! No safety check
152
152
// gets done for this. It is assumed the user knows
153
153
// the range of the values they're reading from the stream.
154
-
byte b8 = in.readByte(); // Nothing left in stream so an error is thrown
154
+
byte b8 = in.nextByte(); // Nothing left in stream so an error is thrown
155
155
```
156
156
157
-
#### .readInt() examples
157
+
#### .nextInt() examples
158
158
```java
159
159
// Suppose standard input stream contains the following byte values we want to read:
0 commit comments