Package org.brijframework.util.resouces
Class FileUtil
- java.lang.Object
-
- org.brijframework.util.resouces.FileUtil
-
public class FileUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description FileUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddeleteAllFile(File file)static voiddeleteAllFile(File file, int offSet)static voiddeleteOldFiles(File directory, int offsetHours)static byte[]getBytesFromInputStream(InputStream inputStream)static byte[]getFileBytes(File file)static String[]getFileLines(File file)static String[]getLines(InputStream inputStream)static Collection<?>getLinesForFile(File file)static byte[]getObjectBytes(Object object)static ObjectgetObjectFromBytes(byte[] bytes)static PropertiesgetProperties(File file, boolean isMandatory)static StringBuffergetStringBuffer(InputStream inputStream)static String[]getStringLines(String str)static voidLineNumberReader(String filePath)static byte[]loadByteArrayFile(File file)static byte[]loadByteFile(File file)static byte[]loadByteFile(String dir, String fileName)static byte[]loadByteFileInBufferMode(File file)static StringloadCharFile(File file)static StringloadCSVFile(String FileName)static byte[]loadFile(File file)static StringloadFile(InputStream stream)static StringloadFile(String path)static StringloadFile(String dir, String fileName)static ObjectloadFromFile(String filePath)static ObjectloadFromNetwork(Object obj)static ObjectloadFromStream(Object obj)static StringloadMultipleFileInSequence(File... files)static PropertiesloadPropertiesFile(String FileName, Properties properties)static PropertiesloadPropetiesFile(String FileName)static byte[]objectToBytes(Object object)static StringreadFile(File file)static ObjectreadObject(byte[] bytes)Converts bytes array to Object.static ObjectreadObject(File file)Converts File to Object.static ObjectreadObjectInLinuxWay(File file)static ObjectreadObjectNewWay(File file)static voidsaveToFile(String filePath, Object obj)static voidsaveToNetwork(Object obj)static voidsaveToStream(Object obj)static voidwriteAedioFile(String filePath, String fileName)static booleanwriteByteFile(File fileName, byte[] data)static booleanwriteByteFile(String fileName, String data, boolean appand)static booleanwriteByteFileInBufferMode(String fileName, String data)static booleanwriteByteFileInBufferMode(String fileName, String data, boolean appand)static booleanwriteCharFile(String fileName, String data)static booleanwriteCharFile(String fileName, String data, boolean appand)static booleanwriteCharInMultipleFle(String[] fileName, String data, boolean appand)static voidwriteClassFile(String filePath, String fileName)static StringwriteCSVFile(String FileName, String data)static StringwriteCSVFile(String filePath, String FileName, StringBuffer data)static voidwriteDOCFile(String filePath, String fileName)static voidwriteFile(File file, byte[] data)static voidwriteFile(File fileName, String data)static voidwriteFileNewWay(File file, byte[] data)static voidwriteFileNewWay(File file, String data)static byte[]writeImageFile(String dirPath, String type, String detail)static voidwriteJARFile(String filePath, String fileName)static voidwriteJSONFile(String filePath, String fileName)static voidwriteObject(File file, Object object)static voidwriteObjectNewWay(File file, Object object)static StringwritePropertiesFile(String filePath, String fileName, String data)static voidwriteVedioFile(String filePath, String fileName)static voidwriteXMLFile(String filePath, String fileName)static voidwriteZIPFile(String filePath, String fileName)
-
-
-
Method Detail
-
loadPropetiesFile
public static Properties loadPropetiesFile(String FileName)
- Parameters:
FileName-- Returns:
- Throws:
FileNotFoundExceptionIOExceptionuse- use to load Properties File and Return PropertiesObject
-
loadPropertiesFile
public static Properties loadPropertiesFile(String FileName, Properties properties)
-
writeObject
public static void writeObject(File file, Object object) throws IOException
- Throws:
IOException
-
readObject
public static Object readObject(File file)
Converts File to Object. Returns null if exception occurs
-
readObject
public static Object readObject(byte[] bytes)
Converts bytes array to Object. Returns null if exception occurs- Parameters:
bytes-Bytearray- Returns:
- object converted by byte array.
-
saveToFile
public static void saveToFile(String filePath, Object obj) throws IOException
- Throws:
IOException
-
loadFromFile
public static Object loadFromFile(String filePath) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
saveToStream
public static void saveToStream(Object obj) throws IOException
- Throws:
IOException
-
loadFromStream
public static Object loadFromStream(Object obj) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
saveToNetwork
public static void saveToNetwork(Object obj) throws IOException
- Throws:
IOException
-
loadFromNetwork
public static Object loadFromNetwork(Object obj) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
getObjectBytes
public static byte[] getObjectBytes(Object object) throws IOException
- Throws:
IOException
-
getLinesForFile
public static Collection<?> getLinesForFile(File file)
-
writeCSVFile
public static String writeCSVFile(String filePath, String FileName, StringBuffer data) throws IOException
- Throws:
IOException
-
writeCSVFile
public static String writeCSVFile(String FileName, String data) throws IOException
- Throws:
IOException
-
writePropertiesFile
public static String writePropertiesFile(String filePath, String fileName, String data) throws IOException
- Throws:
IOException
-
writeByteFile
public static boolean writeByteFile(File fileName, byte[] data)
-
writeByteFile
public static boolean writeByteFile(String fileName, String data, boolean appand) throws IOException
- Throws:
IOException
-
writeByteFileInBufferMode
public static boolean writeByteFileInBufferMode(String fileName, String data) throws Exception
- Throws:
Exception
-
writeByteFileInBufferMode
public static boolean writeByteFileInBufferMode(String fileName, String data, boolean appand) throws Exception
- Throws:
Exception
-
writeCharFile
public static boolean writeCharFile(String fileName, String data) throws IOException
- Throws:
IOException
-
writeCharFile
public static boolean writeCharFile(String fileName, String data, boolean appand) throws IOException
- Throws:
IOException
-
writeCharInMultipleFle
public static boolean writeCharInMultipleFle(String[] fileName, String data, boolean appand) throws Exception
- Throws:
Exception
-
LineNumberReader
public static void LineNumberReader(String filePath)
-
loadFile
public static byte[] loadFile(File file)
-
loadFile
public static String loadFile(String dir, String fileName) throws IOException
- Throws:
IOException
-
loadCSVFile
public static String loadCSVFile(String FileName) throws IOException
- Parameters:
data-FileName-- Returns:
- Throws:
IOException- this method will write data into csv file.
-
loadByteFile
public static byte[] loadByteFile(File file) throws IOException
- Throws:
IOException
-
loadByteFile
public static byte[] loadByteFile(String dir, String fileName) throws IOException
- Throws:
IOException
-
loadByteFileInBufferMode
public static byte[] loadByteFileInBufferMode(File file) throws IOException
- Throws:
IOException
-
loadByteArrayFile
public static byte[] loadByteArrayFile(File file)
-
loadFile
public static String loadFile(InputStream stream)
-
loadMultipleFileInSequence
public static String loadMultipleFileInSequence(File... files) throws IOException
- Throws:
IOException
-
deleteAllFile
public static void deleteAllFile(File file, int offSet)
-
deleteAllFile
public static void deleteAllFile(File file)
-
deleteOldFiles
public static void deleteOldFiles(File directory, int offsetHours)
-
readObjectNewWay
public static Object readObjectNewWay(File file) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
readObjectInLinuxWay
public static Object readObjectInLinuxWay(File file) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
getObjectFromBytes
public static Object getObjectFromBytes(byte[] bytes) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
objectToBytes
public static byte[] objectToBytes(Object object)
-
writeObjectNewWay
public static void writeObjectNewWay(File file, Object object) throws IOException
- Throws:
IOException
-
writeFile
public static void writeFile(File file, byte[] data)
-
writeFileNewWay
public static void writeFileNewWay(File file, byte[] data) throws IOException
- Throws:
IOException
-
writeFileNewWay
public static void writeFileNewWay(File file, String data) throws IOException
- Throws:
IOException
-
readFile
public static String readFile(File file) throws IOException
- Throws:
IOException
-
getStringBuffer
public static StringBuffer getStringBuffer(InputStream inputStream) throws IOException
- Throws:
IOException
-
getStringLines
public static String[] getStringLines(String str) throws IOException
- Throws:
IOException
-
getLines
public static String[] getLines(InputStream inputStream) throws IOException
- Throws:
IOException
-
getFileLines
public static String[] getFileLines(File file) throws IOException
- Throws:
IOException
-
getFileBytes
public static byte[] getFileBytes(File file) throws IOException
- Throws:
IOException
-
getBytesFromInputStream
public static byte[] getBytesFromInputStream(InputStream inputStream) throws IOException
- Throws:
IOException
-
getProperties
public static Properties getProperties(File file, boolean isMandatory)
-
-