|
@@ -36,7 +36,7 @@ import java.util.Stack;
|
36
|
36
|
/**
|
37
|
37
|
* Reads a file in reverse.
|
38
|
38
|
*/
|
39
|
|
-public class ReverseFileReader {
|
|
39
|
+public class ReverseFileReader implements AutoCloseable {
|
40
|
40
|
|
41
|
41
|
/** Path to the file we're reading. */
|
42
|
42
|
private final Path file;
|
|
@@ -91,17 +91,11 @@ public class ReverseFileReader {
|
91
|
91
|
seekLength = newValue;
|
92
|
92
|
}
|
93
|
93
|
|
94
|
|
- /**
|
95
|
|
- * Close the file pointer.
|
96
|
|
- * This should be called before removing the reference to this object
|
97
|
|
- *
|
98
|
|
- * @throws IOException If there is an error closing the file, or if it has been closed already.
|
99
|
|
- */
|
|
94
|
+ @Override
|
100
|
95
|
public void close() throws IOException {
|
101
|
|
- if (!byteChannel.isOpen()) {
|
102
|
|
- throw new IOException("Channel has been closed.");
|
|
96
|
+ if (byteChannel.isOpen()) {
|
|
97
|
+ byteChannel.close();
|
103
|
98
|
}
|
104
|
|
- byteChannel.close();
|
105
|
99
|
}
|
106
|
100
|
|
107
|
101
|
/**
|