Commit 75718947275770e2a462647891d516f59c356a38
1 parent
68ecc41e
git-svn-id: svn://imanolbarba.net/PAD@14 c2ee353e-ed0d-4329-bf56-03aec153487f
Showing
4 changed files
with
9 additions
and
2 deletions
readline/bin/pad/prac1/Console.class
No preview for this file type
readline/bin/pad/prac1/EditableBufferedReader.class
No preview for this file type
readline/src/pad/prac1/Console.java
... | ... | @@ -27,6 +27,7 @@ public class Console implements Observer |
27 | 27 | scanner.findWithinHorizon(pattern,0); |
28 | 28 | numCols = Integer.parseInt(scanner.match().group(2)); |
29 | 29 | numRows = Integer.parseInt(scanner.match().group(1)); |
30 | + scanner.close(); | |
30 | 31 | } |
31 | 32 | |
32 | 33 | public Coordinate getCurrentPos() |
... | ... | @@ -37,8 +38,10 @@ public class Console implements Observer |
37 | 38 | Pattern pattern = Pattern.compile("(\\d+);(\\d+)"); |
38 | 39 | Scanner scanner = new Scanner(System.in); |
39 | 40 | scanner.findWithinHorizon(pattern,0); |
40 | - return new Coordinate(Integer.parseInt(scanner.match().group(2)), | |
41 | - Integer.parseInt(scanner.match().group(1))); | |
41 | + int x = Integer.parseInt(scanner.match().group(2)); | |
42 | + int y = Integer.parseInt(scanner.match().group(1)); | |
43 | + scanner.close(); | |
44 | + return new Coordinate(x,y); | |
42 | 45 | } |
43 | 46 | |
44 | 47 | public void moveCursorTo(Coordinate xy) | ... | ... |
readline/src/pad/prac1/EditableBufferedReader.java
... | ... | @@ -108,6 +108,7 @@ public class EditableBufferedReader extends BufferedReader |
108 | 108 | line.toggleMode(); |
109 | 109 | break; |
110 | 110 | } |
111 | + scanner.close(); | |
111 | 112 | return; |
112 | 113 | } |
113 | 114 | else if(scanner.findWithinHorizon("O?", 0).length() > 0) |
... | ... | @@ -124,8 +125,10 @@ public class EditableBufferedReader extends BufferedReader |
124 | 125 | line.setCursorTo(line.length()+1); |
125 | 126 | break; |
126 | 127 | } |
128 | + scanner.close(); | |
127 | 129 | return; |
128 | 130 | } |
131 | + scanner.close(); | |
129 | 132 | } |
130 | 133 | else |
131 | 134 | { |
... | ... | @@ -147,6 +150,7 @@ public class EditableBufferedReader extends BufferedReader |
147 | 150 | line.addChar((char)character); |
148 | 151 | break; |
149 | 152 | } |
153 | + scanner.close(); | |
150 | 154 | return; |
151 | 155 | } |
152 | 156 | } | ... | ... |