Package org.xipki.util
Class IoUtil
- java.lang.Object
-
- org.xipki.util.IoUtil
-
public class IoUtil extends Object
IO utility class.- Since:
- 2.0.0
- Author:
- Lijun Liao (xipki)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringbase64Encode(byte[] data, boolean withLineBreak)static voidcloseQuietly(Closeable closable)static StringconvertSequenceName(String sequenceName)static booleandeleteDir(File dir)static booleandeleteDir(File dir, boolean prependBaseDir)static booleandeleteFile(File file)static booleandeleteFile(File file, boolean prependBaseDir)static booleandeleteFile(String path)static booleandeleteFile(String path, boolean prependBaseDir)static StringdetectPath(String path)static FileexpandFilepath(File file)static FileexpandFilepath(File file, boolean prependBaseDir)static StringexpandFilepath(String path)static StringexpandFilepath(String path, boolean prependBaseDir)static StringgetHostAddress()static intgetIndex(byte[] arrayA, byte[] arrayB)static PropertiesloadProperties(String path)static PropertiesloadProperties(String path, boolean prependBaseDir)static voidmkdirsParent(Path path)static HttpURLConnectionopenHttpConn(URL url)static intparseInt(byte[] bytes, int offset)static shortparseShort(byte[] bytes, int offset)static byte[]read(File file)static byte[]read(File file, boolean prependBaseDir)static byte[]read(InputStream in)static byte[]read(String fileName)static byte[]read(String fileName, boolean prependBaseDir)static StringreadLastNonBlankLine(File file)static StringreadLineFromConsole(String prompt)static char[]readPasswordFromConsole(String prompt)static voidsave(File file, byte[] content)static voidsave(File file, byte[] content, boolean prependBaseDir)static voidsave(String fileName, byte[] encoded)static voidsave(String fileName, byte[] encoded, boolean prependBaseDir)static voidwriteInt(int value, byte[] dest, int destOffset)static voidwriteShort(short value, byte[] dest, int destOffset)
-
-
-
Method Detail
-
closeQuietly
public static void closeQuietly(Closeable closable)
-
read
public static byte[] read(String fileName) throws IOException
- Throws:
IOException
-
read
public static byte[] read(String fileName, boolean prependBaseDir) throws IOException
- Throws:
IOException
-
read
public static byte[] read(File file) throws IOException
- Throws:
IOException
-
read
public static byte[] read(File file, boolean prependBaseDir) throws IOException
- Throws:
IOException
-
read
public static byte[] read(InputStream in) throws IOException
- Throws:
IOException
-
save
public static void save(String fileName, byte[] encoded) throws IOException
- Throws:
IOException
-
save
public static void save(String fileName, byte[] encoded, boolean prependBaseDir) throws IOException
- Throws:
IOException
-
save
public static void save(File file, byte[] content) throws IOException
- Throws:
IOException
-
save
public static void save(File file, byte[] content, boolean prependBaseDir) throws IOException
- Throws:
IOException
-
mkdirsParent
public static void mkdirsParent(Path path) throws IOException
- Throws:
IOException
-
getHostAddress
public static String getHostAddress() throws SocketException
- Throws:
SocketException
-
deleteFile
public static boolean deleteFile(String path)
-
deleteFile
public static boolean deleteFile(String path, boolean prependBaseDir)
-
deleteFile
public static boolean deleteFile(File file)
-
deleteFile
public static boolean deleteFile(File file, boolean prependBaseDir)
-
deleteDir
public static boolean deleteDir(File dir)
-
deleteDir
public static boolean deleteDir(File dir, boolean prependBaseDir)
-
writeShort
public static void writeShort(short value, byte[] dest, int destOffset)
-
parseShort
public static short parseShort(byte[] bytes, int offset)
-
writeInt
public static void writeInt(int value, byte[] dest, int destOffset)
-
parseInt
public static int parseInt(byte[] bytes, int offset)
-
getIndex
public static int getIndex(byte[] arrayA, byte[] arrayB)
-
base64Encode
public static String base64Encode(byte[] data, boolean withLineBreak)
-
openHttpConn
public static HttpURLConnection openHttpConn(URL url) throws IOException
- Throws:
IOException
-
readPasswordFromConsole
public static char[] readPasswordFromConsole(String prompt)
-
loadProperties
public static Properties loadProperties(String path) throws IOException
- Throws:
IOException
-
loadProperties
public static Properties loadProperties(String path, boolean prependBaseDir) throws IOException
- Throws:
IOException
-
readLastNonBlankLine
public static String readLastNonBlankLine(File file) throws IOException
- Throws:
IOException
-
-