com.nonesole.persistence.tools
Class FileToolkit

java.lang.Object
  extended by com.nonesole.persistence.tools.FileToolkit

public class FileToolkit
extends java.lang.Object

File Tools

Version:
1.0 - build in 2008-03-29
Author:
JACK LEE

Field Summary
static java.lang.String LINE_SEPARATOR
          Line separator
 
Constructor Summary
FileToolkit()
           
 
Method Summary
static java.io.File createNewFile(java.lang.String fullPath)
          Create new file
static java.net.URL getDefaultRootPath()
          Get root path of project
static java.lang.String[] getFileNames(java.lang.String fullPath, java.lang.String suffix)
          Get files' name array in dictionary
static java.io.PrintWriter getPrintWriter(java.lang.String filepath)
          Read file to PrintWriter Object for output
static void insertContentByBufferWriter(java.lang.String file, java.lang.String conent)
          insert content into file
static void insertContentByFileWriter(java.lang.String fileName, java.lang.String content)
          insert content into file
static void insertContentByPrintWriter(java.lang.String file, java.lang.String conent)
          insert content into file
static void insertContentByRondomAccessFile(java.lang.String fileName, java.lang.String content)
          insert content into file
static java.io.File loadFile(java.lang.String fullPath)
          Load file from full path
static java.io.File[] loadFiles(java.lang.String fullPath, java.lang.String suffix)
          Load file array in dictionary
static byte[] loadFileToByteArray(java.lang.String fullPath)
          Read file to byte[]
static java.io.FileInputStream loadFileToInputStream(java.lang.String fullPath)
          Read file to FileInputStream
static java.lang.Object loadFileToObject(java.lang.String fullPath)
          Read file to serialization Object
static java.lang.String loadFileToString(java.lang.String fullPath)
          Read file to String
static java.lang.Object loadFileToXML(java.lang.String url)
          Read JavaBean from File
static java.lang.Object loadFileToXML(java.net.URL url)
          Read JavaBean from File
static java.util.Properties loadProperties(java.lang.String fullPath)
          Read file to Properties Object
static void saveFileFromByteArray(java.lang.String fullPath, byte[] array)
          Save file form byte[]
static void saveFileFromObject(java.lang.String fullPath, java.lang.Object obj)
          Save file form object
static void saveFileFromString(java.lang.String fullPath, java.lang.String str)
          Save file form string
static void saveFileToXML(java.lang.Object obj, java.lang.String url)
          Save JavaBean to File
static void saveFileToXML(java.lang.Object obj, java.net.URL url)
          Save JavaBean to File
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_SEPARATOR

public static final java.lang.String LINE_SEPARATOR
Line separator

See Also:
Constant Field Values
Constructor Detail

FileToolkit

public FileToolkit()
Method Detail

loadFile

public static final java.io.File loadFile(java.lang.String fullPath)
                                   throws java.io.IOException
Load file from full path

Parameters:
fullPath -
Returns:
File Object
Throws:
java.io.IOException

loadFileToInputStream

public static final java.io.FileInputStream loadFileToInputStream(java.lang.String fullPath)
                                                           throws java.io.IOException
Read file to FileInputStream

Parameters:
fullPath -
Returns:
FileInputStream object
Throws:
java.io.IOException

loadFileToObject

public static final java.lang.Object loadFileToObject(java.lang.String fullPath)
                                               throws java.io.IOException,
                                                      java.lang.ClassNotFoundException
Read file to serialization Object

Parameters:
fullPath -
Returns:
Object serialization object
Throws:
java.io.IOException
java.lang.ClassNotFoundException

loadProperties

public static final java.util.Properties loadProperties(java.lang.String fullPath)
                                                 throws java.io.IOException,
                                                        java.lang.ClassNotFoundException
Read file to Properties Object

Parameters:
fullPath -
Returns:
Properties
Throws:
java.io.IOException
java.lang.ClassNotFoundException

loadFileToString

public static final java.lang.String loadFileToString(java.lang.String fullPath)
                                               throws java.io.IOException,
                                                      java.lang.ClassNotFoundException
Read file to String

Parameters:
fullPath -
Returns:
string
Throws:
java.io.IOException
java.lang.ClassNotFoundException

loadFileToByteArray

public static final byte[] loadFileToByteArray(java.lang.String fullPath)
                                        throws java.io.IOException,
                                               java.lang.ClassNotFoundException
Read file to byte[]

Parameters:
fullPath -
Returns:
byte[]
Throws:
java.io.IOException
java.lang.ClassNotFoundException

createNewFile

public static final java.io.File createNewFile(java.lang.String fullPath)
                                        throws java.io.IOException
Create new file

Parameters:
fullPath -
Returns:
File
Throws:
java.io.IOException

saveFileFromObject

public static final void saveFileFromObject(java.lang.String fullPath,
                                            java.lang.Object obj)
                                     throws java.io.IOException
Save file form object

Parameters:
fullPath -
object - needs save
Throws:
java.io.IOException

saveFileFromString

public static final void saveFileFromString(java.lang.String fullPath,
                                            java.lang.String str)
                                     throws java.io.IOException
Save file form string

Parameters:
fullPath -
string -
Throws:
java.io.IOException

saveFileFromByteArray

public static final void saveFileFromByteArray(java.lang.String fullPath,
                                               byte[] array)
                                        throws java.io.IOException
Save file form byte[]

Parameters:
fullPath -
byte[] -
Throws:
java.io.IOException

loadFiles

public static final java.io.File[] loadFiles(java.lang.String fullPath,
                                             java.lang.String suffix)
                                      throws java.io.IOException
Load file array in dictionary

Parameters:
fullPath -
suffix - of file name like ".txt"
Returns:
Files array
Throws:
java.io.IOException

getFileNames

public static final java.lang.String[] getFileNames(java.lang.String fullPath,
                                                    java.lang.String suffix)
                                             throws java.io.IOException
Get files' name array in dictionary

Parameters:
fullPath -
suffix - of file name like ".txt"
Returns:
File names array
Throws:
java.io.IOException

getPrintWriter

public static final java.io.PrintWriter getPrintWriter(java.lang.String filepath)
Read file to PrintWriter Object for output

Parameters:
filepath -
Returns:
PrintWriter object

insertContentByPrintWriter

public static final void insertContentByPrintWriter(java.lang.String file,
                                                    java.lang.String conent)
insert content into file

Parameters:
file -
content -

insertContentByBufferWriter

public static final void insertContentByBufferWriter(java.lang.String file,
                                                     java.lang.String conent)
insert content into file

Parameters:
fileName -
content -

insertContentByFileWriter

public static final void insertContentByFileWriter(java.lang.String fileName,
                                                   java.lang.String content)
insert content into file

Parameters:
fileName -
content -

insertContentByRondomAccessFile

public static final void insertContentByRondomAccessFile(java.lang.String fileName,
                                                         java.lang.String content)
insert content into file

Parameters:
fileName -
content -

getDefaultRootPath

public static final java.net.URL getDefaultRootPath()
Get root path of project

Returns:
URL root path

saveFileToXML

public static final void saveFileToXML(java.lang.Object obj,
                                       java.net.URL url)
                                throws java.io.FileNotFoundException
Save JavaBean to File

Parameters:
obj - JavaBean
url - URL of file
Throws:
java.io.FileNotFoundException

loadFileToXML

public static final java.lang.Object loadFileToXML(java.net.URL url)
                                            throws java.io.FileNotFoundException
Read JavaBean from File

Parameters:
url - URL of file
Returns:
JavaBean
Throws:
java.io.FileNotFoundException

saveFileToXML

public static final void saveFileToXML(java.lang.Object obj,
                                       java.lang.String url)
                                throws java.io.FileNotFoundException
Save JavaBean to File

Parameters:
obj - JavaBean
url - path of file (String)
Throws:
java.io.FileNotFoundException

loadFileToXML

public static final java.lang.Object loadFileToXML(java.lang.String url)
                                            throws java.io.FileNotFoundException
Read JavaBean from File

Parameters:
url - path of file (String)
Returns:
JavaBean
Throws:
java.io.FileNotFoundException