Reader class has been improved
This commit is contained in:
parent
7f06e14ec9
commit
aa16324991
|
@ -1,7 +1,9 @@
|
|||
package serene.simple;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PushbackReader;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Reader {
|
||||
|
@ -22,4 +24,21 @@ public class Reader {
|
|||
return readSymbol(inputStream);
|
||||
}
|
||||
}
|
||||
|
||||
public static ListNode read(InputStream inputStream) throws IOException {
|
||||
return read(new PushbackReader(new InputStreamReader(inputStream)));
|
||||
}
|
||||
|
||||
public static ListNode read(PushbackReader inputStream) throws IOException {
|
||||
List<Node> nodes = new ArrayList<Node>();
|
||||
|
||||
skipWhitespaces(inputStream);
|
||||
|
||||
char c = inputStream.read();
|
||||
while ((byte) c != -1) {
|
||||
inputStream.unread(c);
|
||||
nodes.add(readNode(inputStream));
|
||||
skipWhitespaces(inputStream);
|
||||
c = (char) inputStream.read();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue