|
||||||||||
| 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)
FileUtilspublic HandledFile getHandledFile(String... names)
FileUtilspublic HandledFile getParentHandledFile(String... names)
FileUtils
public OutputStream openOutputStream()
throws Exception
ExceptionfileHandler
public OutputStream openOutputStream(boolean append)
throws Exception
ExceptionfileHandler
public InputStream openInputStream()
throws Exception
ExceptionfileHandler
public void touch(String... names)
throws Exception
ExceptionfileHandlerpublic 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
ExceptionfileHandler
public void copyFile(HandledFile destFile)
throws Exception
ExceptionfileHandler
public long copyFile(OutputStream output)
throws Exception
ExceptionfileHandler
public void copyURLToFile(URL source)
throws Exception
ExceptionfileHandler
public boolean delete()
throws Exception
ExceptionfileHandler
public void cleanDirectory()
throws Exception
ExceptionfileHandlerpublic boolean waitFor(int seconds)
fileHandler
public String readFileToString()
throws Exception
ExceptionfileHandler
public String readFileToString(String encoding)
throws Exception
ExceptionfileHandler
public byte[] readFileToByteArray()
throws Exception
ExceptionfileHandler
public List<String> readLines()
throws Exception
ExceptionfileHandler
public List<String> readLines(String encoding)
throws Exception
ExceptionfileHandler
public void writeStringToFile(String data)
throws Exception
ExceptionfileHandler
public void writeStringToFile(String data,
String encoding)
throws Exception
ExceptionfileHandler
public void writeStringToFile(String data,
boolean append)
throws Exception
ExceptionfileHandler
public void writeStringToFile(String data,
String encoding,
boolean append)
throws Exception
ExceptionfileHandler
public void write(CharSequence data)
throws Exception
ExceptionfileHandler
public void write(CharSequence data,
boolean append)
throws Exception
ExceptionfileHandler
public void write(CharSequence data,
String encoding)
throws Exception
ExceptionfileHandler
public void write(CharSequence data,
String encoding,
boolean append)
throws Exception
ExceptionfileHandler
public void writeByteArrayToFile(byte[] data)
throws Exception
ExceptionfileHandler
public void writeByteArrayToFile(byte[] data,
boolean append)
throws Exception
ExceptionfileHandler
public void copyInputStreamToFile(InputStream inputStream)
throws Exception
inputStream - the input stream to write
Exception
public void writeLines(Collection<?> lines)
throws Exception
ExceptionfileHandler
public void writeLines(Collection<?> lines,
boolean append)
throws Exception
ExceptionfileHandler
public void writeLines(Collection<?> lines,
String lineEnding)
throws Exception
ExceptionfileHandler
public void writeLines(Collection<?> lines,
String lineEnding,
boolean append)
throws Exception
ExceptionfileHandler
public void writeLines(String encoding,
Collection<?> lines)
throws Exception
ExceptionfileHandler
public void writeLines(String encoding,
Collection<?> lines,
boolean append)
throws Exception
ExceptionfileHandler
public void writeLines(String encoding,
Collection<?> lines,
String lineEnding)
throws Exception
ExceptionfileHandler
public void writeLines(String encoding,
Collection<?> lines,
String lineEnding,
boolean append)
throws Exception
ExceptionfileHandler
public void moveFile(HandledFile destFile)
throws Exception
ExceptionfileHandlerpublic long size()
fileHandlerpublic boolean isFileNewer(HandledFile reference)
fileHandlerpublic boolean isFileNewer(File reference)
fileHandlerpublic boolean isFileNewer(Date date)
fileHandlerpublic boolean isFileNewer(long timeMillis)
fileHandlerpublic boolean isFileOlder(HandledFile reference)
fileHandlerpublic boolean isFileOlder(File reference)
fileHandlerpublic boolean isFileOlder(Date date)
fileHandlerpublic boolean isFileOlder(long timeMillis)
fileHandler
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||