1 package org.apache.lucene.store;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import java.io.IOException;
21 import java.io.Closeable;
23 /** Abstract base class for output to a file in a Directory. A random-access
24 * output stream. Used for all Lucene index output operations.
28 public abstract class IndexOutput extends DataOutput implements Closeable {
30 /** Forces any buffered output to be written. */
31 public abstract void flush() throws IOException;
33 /** Closes this stream to further operations. */
34 public abstract void close() throws IOException;
36 /** Returns the current position in this file, where the next write will
40 public abstract long getFilePointer();
42 /** Sets current position in this file, where the next write will occur.
43 * @see #getFilePointer()
45 public abstract void seek(long pos) throws IOException;
47 /** The number of bytes in the file. */
48 public abstract long length() throws IOException;
50 /** Set the file length. By default, this method does
51 * nothing (it's optional for a Directory to implement
52 * it). But, certain Directory implementations (for
53 * example @see FSDirectory) can use this to inform the
54 * underlying IO system to pre-allocate the file to the
55 * specified size. If the length is longer than the
56 * current file length, the bytes added to the file are
57 * undefined. Otherwise the file is truncated.
58 * @param length file length
60 public void setLength(long length) throws IOException {}