| java.lang.Object com.knowgate.dfs.FileSystem
All known Subclasses: com.knowgate.workareas.FileSystemWorkArea,
FileSystem | public class FileSystem (Code) | | Abstract FileSystem object for encasulating NFS and FTP file transfer.
FileSystem can work in 100% Pure Java mode or using native operating system
atomic calls.
This is an alpha state testing module.
author: Sergio Montoro Ten version: 0.7 |
Method Summary | |
public static void | convert(String sFilePath, String sOldCharset, String sNewCharset) Convert a text file from one character set to another
The input file is overwritten. | public boolean | copy(String sSourceURI, String sTargetURI) | public boolean | delete(String sFullURI) | public boolean | delete(String sFullURI, String sDeferedFiles) Mark an URI for deffered deletion
Because web servers often cache and lock files as they are accessed,
it is sometimes not possible to delete recently accessed files inmediately.
This method just appends the given URI at the end of a plain text file
containing a list of file names. | public static String | detectEncoding(File oFile, String sDefault) | public String | detectEncoding(String sFilePath, String sDefault) | protected String | file() | public int | filelen(String sFullURI) | protected String | host() | public boolean | mkdirs(String sFullURI) Create a complete directory branch.
Parameters: sFullURI - Full path of directory to create,ej. | public boolean | move(String sSourceURI, String sTargetURI) | public void | os(int iOperatingSystem) | public void | password(String sPassword) | public String | password() | protected String | path() | public static char[] | readfile(String sFilePath) | public static char[] | readfile(String sFilePath, String sCharSet) | public byte[] | readfilebin(String sFilePath) | public String | readfilestr(String sFilePath, String sEncoding) Read a text file into a String
Parameters: sFilePath - Full path of file to be readed Parameters: sEncoding - Text Encoding for file {UTF-8, ISO-8859-1, ...} if null then if first two bytes of file are FF FE then UTF-8 will be assumed else ISO-8859-1 will be assumed. | public boolean | rename(String sSourceURI, String sTargetURI) Rename file
Parameters: sSourceURI - Source URI (ej. | public boolean | rmdir(String sFullURI) Remove a directory and all its subdirectories and files.
Parameters: sFullURI - Directory URI. | protected void | splitURI(String sURI) | public void | user(String sUser) | public String | user() | public void | writefilebin(String sFilePath, byte[] aBytes) Write a byte array to a text file
Parameters: sFilePath - Full file path. | public void | writefilestr(String sFilePath, String sText, String sEncoding) Write a String to a text file using given encoding
Parameters: sFilePath - Full file path. |
OS_PUREJAVA | final public static int OS_PUREJAVA(Code) | | |
OS_UNIX | final public static int OS_UNIX(Code) | | |
OS_WINDOWS | final public static int OS_WINDOWS(Code) | | |
FileSystem | public FileSystem(int iMode)(Code) | | Create new File System
Operation mode may be set for faster file access throught direct usage
of operating system atomic calls.
User and Password fro FTP access wil be readed from hipergate.cnf file
Parameters: iMode - Operation Mode { OS_PUREJAVA | OS_UNIX | OS_WINDOWS } |
FileSystem | public FileSystem(String sUser, String sPassword)(Code) | | Create new File System
Operation mode will be Pure Java by default
Parameters: sUser - User for FTP access Parameters: sPassword - Password for FTP access |
FileSystem | public FileSystem(int iMode, String sUser, String sPassword)(Code) | | Create new File System
Parameters: iMode - Operation Mode: OS_PUREJAVA or OS_UNIX or OS_WINDOWS Parameters: sUser - User for FTP access Parameters: sPassword - Password for FTP access |
copy | public boolean copy(String sSourceURI, String sTargetURI) throws MalformedURLException, IOException, Exception(Code) | | Copy a file
This method is able to copy a file from local or network disk location
to and FTP location or viceversa.
Parameters: sSourceURI - Source URI, it must have the following syntax:protocol://[server:[port]]/path/filenameEven whe working with local files protocol must be specified, ej.copy ("file:///tmp/upload/image.jpg", "file:///opt/storage/approved/image.jpg") Parameters: sTargetURI - Target URI throws: Exception - throws: IOException - throws: MalformedURLException - |
delete | public boolean delete(String sFullURI) throws IOException(Code) | | Delete o file or directory
Can recursively delete local or FTP directories
Parameters: sFullURI - File or directory URI.For example ftp://localhost/opt/temp/upload/logo.gif true if File or Directory was successfully deleted.This return value should always be checked as Java functions may not returnany error but not delete a directory or file that is in use by another process. throws: IOException - |
delete | public boolean delete(String sFullURI, String sDeferedFiles) throws IOException(Code) | | Mark an URI for deffered deletion
Because web servers often cache and lock files as they are accessed,
it is sometimes not possible to delete recently accessed files inmediately.
This method just appends the given URI at the end of a plain text file
containing a list of file names. This file name list can be later used upon
Web Server re-start for purging files that could no be deleted before because
they where locked.
Parameters: sFullURI - File URI to delete, ej. file:///opt/knowgate/files/deleteme.txt Parameters: sDeferedFiles - Local path to file containing delete list throws: IOException - |
filelen | public int filelen(String sFullURI) throws IOException(Code) | | Get file length
Currently only local and network files length can be queried
Parameters: sFullURI - File URI (protocol+path) File length in bytes throws: IOException - |
mkdirs | public boolean mkdirs(String sFullURI) throws Exception, IOException(Code) | | Create a complete directory branch.
Parameters: sFullURI - Full path of directory to create,ej. file:///tmp/uploads/binaries/imagesej. ftp://ftpserver/tmp/uploads/binaries/images throws: Exception - throws: IOException - |
os | public void os(int iOperatingSystem)(Code) | | Parameters: iOperatingSystem - = { FileSystem.OS_PUREJAVA, FileSystem.OS_UNIX, FileSystem.OS_WINDOWS } |
password | public void password(String sPassword)(Code) | | Parameters: sPassword - Password for FTP access |
password | public String password()(Code) | | sPassword Password for FTP access |
rmdir | public boolean rmdir(String sFullURI) throws IOException(Code) | | Remove a directory and all its subdirectories and files.
Parameters: sFullURI - Directory URI. For example: file:///tmp/upload true if Directory was successfully deleted.This return value should always be checked as Java functions may not returnany error but not delete a directory that is in use by another process. throws: IOException - |
user | public void user(String sUser)(Code) | | Parameters: sUser - user for FTP access |
writefilebin | public void writefilebin(String sFilePath, byte[] aBytes) throws IOException(Code) | | Write a byte array to a text file
Parameters: sFilePath - Full file path. For example "file:///tmp/myfile.bin" or "ftp://localhost:21/tmp/myfile.bin" Parameters: aBytes - Bytes to be written throws: IOException - since: 3.0 |
|
|