com.nonesole.persistence.file
Class FileWrapper

java.lang.Object
  extended by com.nonesole.persistence.file.FileWrapper

public class FileWrapper
extends java.lang.Object

File wrapper

Version:
1.0 - build in 2009-07-22
Author:
JACK LEE

Constructor Summary
FileWrapper(java.net.URL url)
          Construction
 
Method Summary
 void clear()
          Clear and reset parameter.
 void destroy()
          Destroy current object
 boolean hasMore()
          If or not have next line to reading.
 void lock()
          Lock file channel
 java.lang.String readAll()
          Read file to string.
 java.lang.String readAll(boolean isLock)
          Read file to string.
 java.lang.String readLine()
          Read one line of string
 void release()
          Release file channel.
 void replace(java.lang.String regex, java.lang.String replacement)
          Replace what user want to erase or rewrite.
 void setCharset(java.lang.String charset)
          Set current charset
Please refer to com.nonesole.persistence.file.AuailableCharsets
 void write(java.lang.String str)
          Write content at tail of file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileWrapper

public FileWrapper(java.net.URL url)
            throws OperationsException,
                   java.io.IOException
Construction

Parameters:
url - - URL
Throws:
OperationsException
java.io.IOException
Method Detail

setCharset

public void setCharset(java.lang.String charset)
Set current charset
Please refer to com.nonesole.persistence.file.AuailableCharsets

Parameters:
charsetType - the charsetType to set

clear

public void clear()
           throws java.io.IOException
Clear and reset parameter.

Throws:
java.io.IOException

hasMore

public boolean hasMore()
                throws java.io.IOException
If or not have next line to reading.

Returns:
true - readLine() can be used
Throws:
java.io.IOException

readAll

public java.lang.String readAll()
                         throws java.io.IOException
Read file to string.

Returns:
String
Throws:
java.io.IOException

readAll

public java.lang.String readAll(boolean isLock)
                         throws java.io.IOException
Read file to string.

Parameters:
isLock - - true means lock file channel when read file
Returns:
String
Throws:
java.io.IOException

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Read one line of string

Returns:
one line of string
Throws:
java.io.IOException

write

public void write(java.lang.String str)
           throws OperationsException,
                  java.io.IOException
Write content at tail of file

Parameters:
str -
Throws:
OperationsException
java.io.IOException

replace

public void replace(java.lang.String regex,
                    java.lang.String replacement)
             throws java.io.IOException,
                    OperationsException
Replace what user want to erase or rewrite.

Parameters:
regex -
replacement -
Throws:
java.io.IOException
OperationsException

release

public void release()
             throws java.io.IOException
Release file channel.

Throws:
java.io.IOException

destroy

public void destroy()
             throws java.io.IOException
Destroy current object

Throws:
java.io.IOException

lock

public void lock()
          throws java.io.IOException
Lock file channel

Throws:
java.io.IOException