public BytesRef next() throws IOException {boolean success = false;try {scratch = reader.next();if (scratch == null) {reader.close();}success = true;return scratch;} finally {if (!success) {IOUtils.closeWhileHandlingException(reader);}}}

public virtual BytesRef Next(){if (scratch == null){return null;}bool success = false;try{byte[] next = reader.Read();if (next != null){scratch.Bytes = next;scratch.Length = next.Length;scratch.Offset = 0;}else{IOUtils.Dispose(reader);scratch = null;}success = true;return scratch;}finally{if (!success){IOUtils.DisposeWhileHandlingException(reader);}}}
