Class LocalTsFileOutput
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.iotdb.tsfile.write.writer.LocalTsFileOutput
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable,TsFileOutput
public class LocalTsFileOutput extends java.io.OutputStream implements TsFileOutput
a TsFileOutput implementation with FileOutputStream. If the file is not existed, it will be created. Otherwise the file will be written from position 0.
-
-
Constructor Summary
Constructors Constructor Description LocalTsFileOutput(java.io.FileOutputStream outputStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()close the output.voidflush()the same withOutputStream.flush().longgetPosition()gets the current position of the Output.voidtruncate(long size)The same withFileChannel.truncate(long).java.io.OutputStreamwrapAsStream()convert this TsFileOutput as a outputstream.voidwrite(byte b)Writes 1 byte to this output at the current position.voidwrite(byte[] b)Writesb.lengthbytes from the specified byte array to this output at the current position.voidwrite(byte[] buf, int start, int offset)voidwrite(int b)voidwrite(java.nio.ByteBuffer b)Writesb.remaining()bytes from the specified byte array to this output at the current position.
-
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOExceptionDescription copied from interface:TsFileOutputWritesb.lengthbytes from the specified byte array to this output at the current position.- Specified by:
writein interfaceTsFileOutput- Overrides:
writein classjava.io.OutputStream- Parameters:
b- the data.- Throws:
java.io.IOException- if an I/O error occurs.
-
write
public void write(byte b) throws java.io.IOExceptionDescription copied from interface:TsFileOutputWrites 1 byte to this output at the current position.- Specified by:
writein interfaceTsFileOutput- Parameters:
b- the data.- Throws:
java.io.IOException- if an I/O error occurs.
-
write
public void write(byte[] buf, int start, int offset) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(java.nio.ByteBuffer b) throws java.io.IOExceptionDescription copied from interface:TsFileOutputWritesb.remaining()bytes from the specified byte array to this output at the current position.- Specified by:
writein interfaceTsFileOutput- Parameters:
b- the data.- Throws:
java.io.IOException- if an I/O error occurs.
-
getPosition
public long getPosition()
Description copied from interface:TsFileOutputgets the current position of the Output. This method is usually used for recording where the data is.
For example, if the Output is a fileOutputStream, then getPosition returns its file position.- Specified by:
getPositionin interfaceTsFileOutput- Returns:
- current position
-
close
public void close() throws java.io.IOExceptionDescription copied from interface:TsFileOutputclose the output.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceTsFileOutput- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException- if an I/O error occurs.
-
wrapAsStream
public java.io.OutputStream wrapAsStream()
Description copied from interface:TsFileOutputconvert this TsFileOutput as a outputstream.- Specified by:
wrapAsStreamin interfaceTsFileOutput- Returns:
- an output stream whose position is the same with this Output
-
flush
public void flush() throws java.io.IOExceptionDescription copied from interface:TsFileOutputthe same withOutputStream.flush().- Specified by:
flushin interfacejava.io.Flushable- Specified by:
flushin interfaceTsFileOutput- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException- if an I/O error occurs.
-
truncate
public void truncate(long size) throws java.io.IOExceptionDescription copied from interface:TsFileOutputThe same withFileChannel.truncate(long).- Specified by:
truncatein interfaceTsFileOutput- Parameters:
size- size The new size, a non-negative byte count- Throws:
java.io.IOException
-
-