1
0

[MINOR] Fix missing @Override annotation on BufferedRandomAccessFile method (#1236)

This commit is contained in:
lamber-ken
2020-01-17 03:14:39 +08:00
committed by vinoth chandar
parent b39458b008
commit 8a3a50309b

View File

@@ -130,6 +130,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile {
* Close the file, after flushing data in the buffer. * Close the file, after flushing data in the buffer.
* @throws IOException * @throws IOException
*/ */
@Override
public void close() throws IOException { public void close() throws IOException {
if (!isClosed) { if (!isClosed) {
this.flush(); this.flush();
@@ -209,6 +210,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile {
* @param pos - position in the file to be loaded to the buffer. * @param pos - position in the file to be loaded to the buffer.
* @throws IOException * @throws IOException
*/ */
@Override
public void seek(long pos) throws IOException { public void seek(long pos) throws IOException {
if (pos >= this.validLastPosition || pos < this.startPosition) { if (pos >= this.validLastPosition || pos < this.startPosition) {
// seeking outside of current buffer -- flush and read // seeking outside of current buffer -- flush and read
@@ -230,6 +232,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile {
/** /**
* @return current file position * @return current file position
*/ */
@Override
public long getFilePointer() { public long getFilePointer() {
return this.currentPosition; return this.currentPosition;
} }
@@ -239,6 +242,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile {
* @return - length of the file (including data yet to be flushed to the file). * @return - length of the file (including data yet to be flushed to the file).
* @throws IOException * @throws IOException
*/ */
@Override
public long length() throws IOException { public long length() throws IOException {
return Math.max(this.currentPosition, super.length()); return Math.max(this.currentPosition, super.length());
} }
@@ -275,6 +279,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile {
* @return - returns a byte as an integer. * @return - returns a byte as an integer.
* @throws IOException * @throws IOException
*/ */
@Override
public int read() throws IOException { public int read() throws IOException {
if (endOfBufferReached()) { if (endOfBufferReached()) {
if (!loadNewBlockToBuffer()) { if (!loadNewBlockToBuffer()) {
@@ -291,6 +296,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile {
* @return - returns number of bytes read. * @return - returns number of bytes read.
* @throws IOException * @throws IOException
*/ */
@Override
public int read(byte[] b) throws IOException { public int read(byte[] b) throws IOException {
return this.read(b, 0, b.length); return this.read(b, 0, b.length);
} }
@@ -303,6 +309,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile {
* @return - number of bytes read. * @return - number of bytes read.
* @throws IOException * @throws IOException
*/ */
@Override
public int read(byte[] b, int off, int len) throws IOException { public int read(byte[] b, int off, int len) throws IOException {
if (endOfBufferReached()) { if (endOfBufferReached()) {
if (!loadNewBlockToBuffer()) { if (!loadNewBlockToBuffer()) {
@@ -337,6 +344,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile {
* @param v - value to be written * @param v - value to be written
* @throws IOException * @throws IOException
*/ */
@Override
public void write(int v) throws IOException { public void write(int v) throws IOException {
byte [] b = new byte[1]; byte [] b = new byte[1];
b[0] = (byte) v; b[0] = (byte) v;
@@ -348,6 +356,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile {
* @param b - byte array with data to be written * @param b - byte array with data to be written
* @throws IOException * @throws IOException
*/ */
@Override
public void write(byte[] b) throws IOException { public void write(byte[] b) throws IOException {
this.write(b, 0, b.length); this.write(b, 0, b.length);
} }
@@ -359,6 +368,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile {
* @param len - length of bytes to be written * @param len - length of bytes to be written
* @throws IOException * @throws IOException
*/ */
@Override
public void write(byte[] b, int off, int len) throws IOException { public void write(byte[] b, int off, int len) throws IOException {
// As all data may not fit into the buffer, more than one write would be required. // As all data may not fit into the buffer, more than one write would be required.
while (len > 0) { while (len > 0) {