diff --git a/readline/bin/pad/prac1/Console.class b/readline/bin/pad/prac1/Console.class index b2070fc..8af3d5d 100644 --- a/readline/bin/pad/prac1/Console.class +++ b/readline/bin/pad/prac1/Console.class diff --git a/readline/bin/pad/prac1/EditableBufferedReader.class b/readline/bin/pad/prac1/EditableBufferedReader.class index 04bc8ab..c6186cb 100644 --- a/readline/bin/pad/prac1/EditableBufferedReader.class +++ b/readline/bin/pad/prac1/EditableBufferedReader.class diff --git a/readline/src/pad/prac1/Console.java b/readline/src/pad/prac1/Console.java index 462ea52..1f5a848 100644 --- a/readline/src/pad/prac1/Console.java +++ b/readline/src/pad/prac1/Console.java @@ -27,6 +27,7 @@ public class Console implements Observer scanner.findWithinHorizon(pattern,0); numCols = Integer.parseInt(scanner.match().group(2)); numRows = Integer.parseInt(scanner.match().group(1)); + scanner.close(); } public Coordinate getCurrentPos() @@ -37,8 +38,10 @@ public class Console implements Observer Pattern pattern = Pattern.compile("(\\d+);(\\d+)"); Scanner scanner = new Scanner(System.in); scanner.findWithinHorizon(pattern,0); - return new Coordinate(Integer.parseInt(scanner.match().group(2)), - Integer.parseInt(scanner.match().group(1))); + int x = Integer.parseInt(scanner.match().group(2)); + int y = Integer.parseInt(scanner.match().group(1)); + scanner.close(); + return new Coordinate(x,y); } public void moveCursorTo(Coordinate xy) diff --git a/readline/src/pad/prac1/EditableBufferedReader.java b/readline/src/pad/prac1/EditableBufferedReader.java index 4bfb6e3..b0d2d99 100644 --- a/readline/src/pad/prac1/EditableBufferedReader.java +++ b/readline/src/pad/prac1/EditableBufferedReader.java @@ -108,6 +108,7 @@ public class EditableBufferedReader extends BufferedReader line.toggleMode(); break; } + scanner.close(); return; } else if(scanner.findWithinHorizon("O?", 0).length() > 0) @@ -124,8 +125,10 @@ public class EditableBufferedReader extends BufferedReader line.setCursorTo(line.length()+1); break; } + scanner.close(); return; } + scanner.close(); } else { @@ -147,6 +150,7 @@ public class EditableBufferedReader extends BufferedReader line.addChar((char)character); break; } + scanner.close(); return; } }