Package org.apache.iotdb.commons.utils
Class IOUtils
- java.lang.Object
-
- org.apache.iotdb.commons.utils.IOUtils
-
public class IOUtils extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.nio.ByteBufferclone(java.nio.ByteBuffer original)static PathPrivilegereadPathPrivilege(java.io.DataInputStream inputStream, java.lang.String encoding, java.lang.ThreadLocal<byte[]> strBufferLocal)Read a PathPrivilege from the given stream.static java.lang.StringreadString(java.io.DataInputStream inputStream, java.lang.String encoding, java.lang.ThreadLocal<byte[]> strBufferLocal)Read a string from the given stream.static voidreplaceFile(java.io.File newFile, java.io.File oldFile)Replace newFile with oldFile.static voidwriteInt(java.io.OutputStream outputStream, int i, java.lang.ThreadLocal<java.nio.ByteBuffer> encodingBufferLocal)Write an integer into the given stream.static voidwritePathPrivilege(java.io.OutputStream outputStream, PathPrivilege pathPrivilege, java.lang.String encoding, java.lang.ThreadLocal<java.nio.ByteBuffer> encodingBufferLocal)Write a PathPrivilege to the given stream.static voidwriteString(java.io.OutputStream outputStream, java.lang.String str, java.lang.String encoding, java.lang.ThreadLocal<java.nio.ByteBuffer> encodingBufferLocal)Write a string into the given stream.
-
-
-
Method Detail
-
writeString
public static void writeString(java.io.OutputStream outputStream, java.lang.String str, java.lang.String encoding, java.lang.ThreadLocal<java.nio.ByteBuffer> encodingBufferLocal) throws java.io.IOExceptionWrite a string into the given stream.- Parameters:
outputStream- the destination to insert.str- the string to be written.encoding- string encoding like 'utf-8'.encodingBufferLocal- a ThreadLocal buffer may be passed to avoid frequently memory allocations. A null may also be passed to use a local buffer.- Throws:
java.io.IOException- when an exception raised during operating the stream.
-
writeInt
public static void writeInt(java.io.OutputStream outputStream, int i, java.lang.ThreadLocal<java.nio.ByteBuffer> encodingBufferLocal) throws java.io.IOExceptionWrite an integer into the given stream.- Parameters:
outputStream- the destination to insert.i- the integer to be written.encodingBufferLocal- a ThreadLocal buffer may be passed to avoid frequently memory allocations. A null may also be passed to use a local buffer.- Throws:
java.io.IOException- when an exception raised during operating the stream.
-
readString
public static java.lang.String readString(java.io.DataInputStream inputStream, java.lang.String encoding, java.lang.ThreadLocal<byte[]> strBufferLocal) throws java.io.IOExceptionRead a string from the given stream.- Parameters:
inputStream- the source to read.encoding- string encoding like 'utf-8'.strBufferLocal- a ThreadLocal buffer may be passed to avoid frequently memory allocations. A null may also be passed to use a local buffer.- Returns:
- a string read from the stream.
- Throws:
java.io.IOException- when an exception raised during operating the stream.
-
readPathPrivilege
public static PathPrivilege readPathPrivilege(java.io.DataInputStream inputStream, java.lang.String encoding, java.lang.ThreadLocal<byte[]> strBufferLocal) throws java.io.IOException, IllegalPathException
Read a PathPrivilege from the given stream.- Parameters:
inputStream- the source to read.encoding- string encoding like 'utf-8'.strBufferLocal- a ThreadLocal buffer may be passed to avoid frequently memory allocations. A null may also be passed to use a local buffer.- Returns:
- a PathPrivilege read from the stream.
- Throws:
java.io.IOException- when an exception raised during operating the stream.IllegalPathException
-
writePathPrivilege
public static void writePathPrivilege(java.io.OutputStream outputStream, PathPrivilege pathPrivilege, java.lang.String encoding, java.lang.ThreadLocal<java.nio.ByteBuffer> encodingBufferLocal) throws java.io.IOExceptionWrite a PathPrivilege to the given stream.- Parameters:
outputStream- the destination to insert.pathPrivilege- the PathPrivilege to be written.encoding- string encoding like 'utf-8'.encodingBufferLocal- a ThreadLocal buffer may be passed to avoid frequently memory allocations. A null may also be passed to use a local buffer.- Throws:
java.io.IOException- when an exception raised during operating the stream.
-
replaceFile
public static void replaceFile(java.io.File newFile, java.io.File oldFile) throws java.io.IOExceptionReplace newFile with oldFile. If the file system does not support atomic file replacement then delete the old file first.- Parameters:
newFile- the new file.oldFile- the file to be replaced.- Throws:
java.io.IOException
-
clone
public static java.nio.ByteBuffer clone(java.nio.ByteBuffer original)
-
-