|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.silverpeas.process.io.file.HandledFile
public class HandledFile
This class permits to manipulate files (read/write/delete/...) into transactional processes. It
encapsulates a FileHandler
instance and knows the root path repository into that it
have to work. FileHandler.getHandledFile
method has to be called to obtain a
HandledFile
instance. With HandledFile
instance, file manipulations are
easier and lighter due to the hiding of internal mechanism.
Field Summary | |
---|---|
protected File |
file
|
protected FileHandler |
fileHandler
|
Constructor Summary | |
---|---|
protected |
HandledFile(FileBasePath basePath,
FileHandler fileHandler,
File file)
Default constructor |
Method Summary | |
---|---|
void |
cleanDirectory()
|
boolean |
contentEquals(HandledFile otherFile)
The given file is handled |
void |
copyFile(HandledFile destFile)
The given file is handled |
long |
copyFile(OutputStream output)
The given file is handled |
void |
copyInputStreamToFile(InputStream inputStream)
Use this method prior to writeByteArrayToFile in order to process very large file |
void |
copyURLToFile(URL source)
The given file is handled |
boolean |
delete()
|
boolean |
exists(String... names)
Indicates if the file exists in session or in real path. |
FileBasePath |
getBasePath()
|
File |
getFile()
|
FileHandler |
getFileHandler()
|
HandledFile |
getHandledFile(String... names)
Gets a sub file from the current HandledFile. |
HandledFile |
getParentHandledFile(String... names)
Gets a sub file from the parent of the current HandledFile. |
String |
getRealPath()
Gets the real path of the file, even if the file exists only in the session path |
boolean |
isFileNewer(Date date)
|
boolean |
isFileNewer(File reference)
|
boolean |
isFileNewer(HandledFile reference)
|
boolean |
isFileNewer(long timeMillis)
|
boolean |
isFileOlder(Date date)
|
boolean |
isFileOlder(File reference)
|
boolean |
isFileOlder(HandledFile reference)
|
boolean |
isFileOlder(long timeMillis)
|
Collection<HandledFile> |
listFiles(boolean recursive,
String... extensions)
|
Collection<HandledFile> |
listFiles(org.apache.commons.io.filefilter.IOFileFilter fileFilter,
org.apache.commons.io.filefilter.IOFileFilter dirFilter)
|
Collection<HandledFile> |
listFiles(String... extensions)
|
void |
moveFile(HandledFile destFile)
Given file is handled |
InputStream |
openInputStream()
|
OutputStream |
openOutputStream()
|
OutputStream |
openOutputStream(boolean append)
|
byte[] |
readFileToByteArray()
|
String |
readFileToString()
|
String |
readFileToString(String encoding)
|
List<String> |
readLines()
|
List<String> |
readLines(String encoding)
|
long |
size()
|
void |
touch(String... names)
|
boolean |
waitFor(int seconds)
|
void |
write(CharSequence data)
|
void |
write(CharSequence data,
boolean append)
|
void |
write(CharSequence data,
String encoding)
|
void |
write(CharSequence data,
String encoding,
boolean append)
|
void |
writeByteArrayToFile(byte[] data)
|
void |
writeByteArrayToFile(byte[] data,
boolean append)
|
void |
writeLines(Collection<?> lines)
|
void |
writeLines(Collection<?> lines,
boolean append)
|
void |
writeLines(Collection<?> lines,
String lineEnding)
|
void |
writeLines(Collection<?> lines,
String lineEnding,
boolean append)
|
void |
writeLines(String encoding,
Collection<?> lines)
|
void |
writeLines(String encoding,
Collection<?> lines,
boolean append)
|
void |
writeLines(String encoding,
Collection<?> lines,
String lineEnding)
|
void |
writeLines(String encoding,
Collection<?> lines,
String lineEnding,
boolean append)
|
void |
writeStringToFile(String data)
|
void |
writeStringToFile(String data,
boolean append)
|
void |
writeStringToFile(String data,
String encoding)
|
void |
writeStringToFile(String data,
String encoding,
boolean append)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final FileHandler fileHandler
protected final File file
Constructor Detail |
---|
protected HandledFile(FileBasePath basePath, FileHandler fileHandler, File file)
basePath
- fileHandler
- file
- Method Detail |
---|
public FileBasePath getBasePath()
public FileHandler getFileHandler()
public String getRealPath()
public File getFile()
public boolean exists(String... names)
FileUtils
public HandledFile getHandledFile(String... names)
FileUtils
public HandledFile getParentHandledFile(String... names)
FileUtils
public OutputStream openOutputStream() throws Exception
Exception
fileHandler
public OutputStream openOutputStream(boolean append) throws Exception
Exception
fileHandler
public InputStream openInputStream() throws Exception
Exception
fileHandler
public void touch(String... names) throws Exception
Exception
fileHandler
public Collection<HandledFile> listFiles(String... extensions)
fileHandler
public Collection<HandledFile> listFiles(boolean recursive, String... extensions)
fileHandler
public Collection<HandledFile> listFiles(org.apache.commons.io.filefilter.IOFileFilter fileFilter, org.apache.commons.io.filefilter.IOFileFilter dirFilter)
fileHandler
public boolean contentEquals(HandledFile otherFile) throws Exception
Exception
fileHandler
public void copyFile(HandledFile destFile) throws Exception
Exception
fileHandler
public long copyFile(OutputStream output) throws Exception
Exception
fileHandler
public void copyURLToFile(URL source) throws Exception
Exception
fileHandler
public boolean delete() throws Exception
Exception
fileHandler
public void cleanDirectory() throws Exception
Exception
fileHandler
public boolean waitFor(int seconds)
fileHandler
public String readFileToString() throws Exception
Exception
fileHandler
public String readFileToString(String encoding) throws Exception
Exception
fileHandler
public byte[] readFileToByteArray() throws Exception
Exception
fileHandler
public List<String> readLines() throws Exception
Exception
fileHandler
public List<String> readLines(String encoding) throws Exception
Exception
fileHandler
public void writeStringToFile(String data) throws Exception
Exception
fileHandler
public void writeStringToFile(String data, String encoding) throws Exception
Exception
fileHandler
public void writeStringToFile(String data, boolean append) throws Exception
Exception
fileHandler
public void writeStringToFile(String data, String encoding, boolean append) throws Exception
Exception
fileHandler
public void write(CharSequence data) throws Exception
Exception
fileHandler
public void write(CharSequence data, boolean append) throws Exception
Exception
fileHandler
public void write(CharSequence data, String encoding) throws Exception
Exception
fileHandler
public void write(CharSequence data, String encoding, boolean append) throws Exception
Exception
fileHandler
public void writeByteArrayToFile(byte[] data) throws Exception
Exception
fileHandler
public void writeByteArrayToFile(byte[] data, boolean append) throws Exception
Exception
fileHandler
public void copyInputStreamToFile(InputStream inputStream) throws Exception
inputStream
- the input stream to write
Exception
public void writeLines(Collection<?> lines) throws Exception
Exception
fileHandler
public void writeLines(Collection<?> lines, boolean append) throws Exception
Exception
fileHandler
public void writeLines(Collection<?> lines, String lineEnding) throws Exception
Exception
fileHandler
public void writeLines(Collection<?> lines, String lineEnding, boolean append) throws Exception
Exception
fileHandler
public void writeLines(String encoding, Collection<?> lines) throws Exception
Exception
fileHandler
public void writeLines(String encoding, Collection<?> lines, boolean append) throws Exception
Exception
fileHandler
public void writeLines(String encoding, Collection<?> lines, String lineEnding) throws Exception
Exception
fileHandler
public void writeLines(String encoding, Collection<?> lines, String lineEnding, boolean append) throws Exception
Exception
fileHandler
public void moveFile(HandledFile destFile) throws Exception
Exception
fileHandler
public long size()
fileHandler
public boolean isFileNewer(HandledFile reference)
fileHandler
public boolean isFileNewer(File reference)
fileHandler
public boolean isFileNewer(Date date)
fileHandler
public boolean isFileNewer(long timeMillis)
fileHandler
public boolean isFileOlder(HandledFile reference)
fileHandler
public boolean isFileOlder(File reference)
fileHandler
public boolean isFileOlder(Date date)
fileHandler
public boolean isFileOlder(long timeMillis)
fileHandler
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |