public class IOUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
BYTE_LENGTH |
static int |
CHAR_LENGTH |
static boolean |
FORCE_META_DATA |
static int |
INT_LENGTH |
static int |
LONG_LENGTH |
static int |
SHORT_LENGTH |
| 构造器和说明 |
|---|
IOUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
copyFile(String sourcePath,
String sourceFileName,
String targetPath,
String targetFileName,
boolean append)
Copy files
|
static boolean |
deleteDir(File dir)
Delete a file or directory
|
static void |
deleteDirChild(File dir)
Delete all subdirectories or files in the directory
|
static byte |
getByte(byte[] memory,
int index) |
static int |
getInt(io.netty.util.AsciiString memory) |
static int |
getInt(byte[] memory,
int index) |
static int |
getIntLE(byte[] memory,
int index) |
static long |
getLong(byte[] memory,
int index) |
static long |
getLongLE(byte[] memory,
int index) |
static short |
getShort(byte[] memory,
int index) |
static short |
getShortLE(byte[] memory,
int index) |
static String |
getString(byte[] memory,
Charset charset) |
static int |
getUnsignedByte(byte[] memory,
int index) |
static long |
getUnsignedInt(byte[] memory,
int index) |
static int |
getUnsignedMedium(byte[] memory,
int index) |
static int |
getUnsignedMediumLE(byte[] memory,
int index) |
static int |
getUnsignedShort(byte[] memory,
int index) |
static int |
indexOf(io.netty.buffer.ByteBuf byteBuf,
byte value) |
static void |
main(String[] args) |
static byte[] |
merge(byte[] bytes1,
byte[] bytes2)
byte merge
|
static FileInputStream |
newFileInputStream(String sourcePath,
String sourceFileName)
newFileInputStream (note: close it after using)
|
static FileOutputStream |
newFileOutputStream(String targetPath,
String targetFileName,
boolean append)
newFileOutputStream (note: close it after using)
|
static io.netty.buffer.ByteBuf |
readFileToByteBuf(String sourcePath,
String sourceFileName)
Read the file to bytebuffer.
|
static byte[] |
readFileToBytes(String sourcePath,
String sourceFileName)
Read file to byte[]
|
static String |
readFileToString(String sourcePath,
String sourceFileName,
String charset)
Read the file
|
static String |
readInput(InputStream inputStream)
Read input stream
|
static String |
readInput(InputStream inputStream,
String encode) |
static long |
readLong(InputStream in) |
static void |
setByte(byte[] memory,
int index,
int value) |
static void |
setInt(byte[] memory,
int index,
int value) |
static void |
setIntLE(byte[] memory,
int index,
int value) |
static void |
setLong(byte[] memory,
int index,
long value) |
static void |
setLongLE(byte[] memory,
int index,
long value) |
static void |
setMedium(byte[] memory,
int index,
int value) |
static void |
setMediumLE(byte[] memory,
int index,
int value) |
static void |
setShort(byte[] memory,
int index,
int value) |
static void |
setShortLE(byte[] memory,
int index,
int value) |
static String |
trimFilename(String fileName) |
static File |
writeFile(byte[] data,
String targetPath,
String targetFileName,
boolean append)
writeFile
|
static File |
writeFile(InputStream in,
String targetPath,
String targetFileName,
boolean append)
writeFile
|
static File |
writeFile(Iterator<ByteBuffer> dataIterator,
String targetPath,
String targetFileName,
boolean append)
writeFile
|
static void |
writerModeToReadMode(io.netty.buffer.ByteBuf byteBuf)
Write mode to read mode
|
public static final int BYTE_LENGTH
public static final int INT_LENGTH
public static final int CHAR_LENGTH
public static final int SHORT_LENGTH
public static final int LONG_LENGTH
public static boolean FORCE_META_DATA
public static byte[] merge(byte[] bytes1,
byte[] bytes2)
bytes1 - bytes1bytes2 - bytes2public static void writerModeToReadMode(io.netty.buffer.ByteBuf byteBuf)
byteBuf - byteBufpublic static void copyFile(String sourcePath, String sourceFileName, String targetPath, String targetFileName, boolean append) throws FileNotFoundException, IOException
sourcePath - sourcePathsourceFileName - sourceFileNametargetPath - targetPathtargetFileName - targetFileNameappend - Whether to concatenate old dataFileNotFoundException - FileNotFoundExceptionIOException - IOExceptionpublic static File writeFile(byte[] data, String targetPath, String targetFileName, boolean append) throws IOException
data - datatargetPath - targetPathtargetFileName - targetFileNameappend - Whether to concatenate old dataIOException - IOExceptionpublic static File writeFile(InputStream in, String targetPath, String targetFileName, boolean append) throws IOException
in - datatargetPath - targetPathtargetFileName - targetFileNameappend - Whether to concatenate old dataIOException - IOExceptionpublic static File writeFile(Iterator<ByteBuffer> dataIterator, String targetPath, String targetFileName, boolean append) throws IOException
dataIterator - datatargetPath - targetPathtargetFileName - targetFileNameappend - Whether to concatenate old dataIOException - IOExceptionpublic static io.netty.buffer.ByteBuf readFileToByteBuf(String sourcePath, String sourceFileName) throws FileNotFoundException, IOException
sourcePath - sourcePathsourceFileName - sourceFileNameFileNotFoundException - FileNotFoundExceptionIOException - IOExceptionpublic static byte[] readFileToBytes(String sourcePath, String sourceFileName) throws FileNotFoundException, IOException
sourcePath - sourcePathsourceFileName - sourceFileNameFileNotFoundException - FileNotFoundExceptionIOException - IOExceptionpublic static String readFileToString(String sourcePath, String sourceFileName, String charset) throws FileNotFoundException
sourcePath - sourcePathsourceFileName - sourceFileNamecharset - charsetFileNotFoundException - FileNotFoundExceptionpublic static String readInput(InputStream inputStream)
inputStream - inputStreampublic static String readInput(InputStream inputStream, String encode)
public static FileOutputStream newFileOutputStream(String targetPath, String targetFileName, boolean append) throws IOException
targetPath - targetPathtargetFileName - targetFileNameappend - Whether to concatenate old dataFileNotFoundException - FileNotFoundExceptionIOExceptionpublic static FileInputStream newFileInputStream(String sourcePath, String sourceFileName) throws FileNotFoundException
sourcePath - sourcePathsourceFileName - sourceFileNameFileNotFoundException - FileNotFoundExceptionpublic static int indexOf(io.netty.buffer.ByteBuf byteBuf,
byte value)
public static void deleteDirChild(File dir)
dir - Folder pathpublic static boolean deleteDir(File dir)
dir - Folder path or file pathpublic static long readLong(InputStream in) throws IOException
IOExceptionpublic static byte getByte(byte[] memory,
int index)
public static short getShort(byte[] memory,
int index)
public static short getShortLE(byte[] memory,
int index)
public static long getUnsignedInt(byte[] memory,
int index)
public static int getUnsignedByte(byte[] memory,
int index)
public static int getUnsignedShort(byte[] memory,
int index)
public static int getUnsignedMedium(byte[] memory,
int index)
public static int getUnsignedMediumLE(byte[] memory,
int index)
public static int getInt(byte[] memory,
int index)
public static int getInt(io.netty.util.AsciiString memory)
public static int getIntLE(byte[] memory,
int index)
public static long getLong(byte[] memory,
int index)
public static long getLongLE(byte[] memory,
int index)
public static void setByte(byte[] memory,
int index,
int value)
public static void setShort(byte[] memory,
int index,
int value)
public static void setShortLE(byte[] memory,
int index,
int value)
public static void setMedium(byte[] memory,
int index,
int value)
public static void setMediumLE(byte[] memory,
int index,
int value)
public static void setInt(byte[] memory,
int index,
int value)
public static void setIntLE(byte[] memory,
int index,
int value)
public static void setLong(byte[] memory,
int index,
long value)
public static void setLongLE(byte[] memory,
int index,
long value)
public static void main(String[] args) throws InterruptedException
Copyright © 2021. All rights reserved.