|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.knowgate.dfs.FileSystem
public class FileSystem
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.
| Field Summary | |
|---|---|
static int |
OS_PUREJAVA
|
static int |
OS_UNIX
|
static int |
OS_WINDOWS
|
protected java.lang.String |
SLASH
|
| Constructor Summary | |
|---|---|
FileSystem()
Create new File System Operation mode will be Pure Java by default User and Password fro FTP access wil be readed from hipergate.cnf file |
|
FileSystem(int iMode)
Create new File System Operation mode may be set for faster file access throught direct usage of operating system atomic calls. |
|
FileSystem(int iMode,
java.lang.String sUser,
java.lang.String sPassword)
Create new File System |
|
FileSystem(java.util.Properties oProps)
|
|
FileSystem(java.lang.String sUser,
java.lang.String sPassword)
Create new File System Operation mode will be Pure Java by default |
|
FileSystem(java.lang.String sUser,
java.lang.String sPassword,
java.lang.String sRealm)
Create new File System Operation mode will be Pure Java by default |
|
| Method Summary | |
|---|---|
static void |
convert(java.lang.String sFilePath,
java.lang.String sOldCharset,
java.lang.String sNewCharset)
Convert a text file from one character set to another The input file is overwritten. |
boolean |
copy(java.lang.String sSourceURI,
java.lang.String sTargetURI)
Copy a file This method is able to copy a file from local or network disk location to and FTP location or viceversa. |
boolean |
delete(java.lang.String sFullURI)
Delete o file or directory Can recursively delete local or FTP directories |
boolean |
delete(java.lang.String sFullURI,
java.lang.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. |
static java.lang.String |
detectEncoding(java.io.File oFile,
java.lang.String sDefault)
Detect file encoding |
java.lang.String |
detectEncoding(java.lang.String sFilePath,
java.lang.String sDefault)
Detect file encoding |
void |
downloadhtmlpage(java.lang.String sBasePath,
java.lang.String sFilePath,
java.io.OutputStream oOutStrm)
Download an HTML page and all its referenced files into a ZIP |
boolean |
exists(java.lang.String sSourceURI)
Checks whether a file or directory exists |
protected java.lang.String |
file()
|
int |
filelen(java.lang.String sFullURI)
Get file length Currently only local and network files length can be queried |
protected java.lang.String |
host()
|
boolean |
mkdirs(java.lang.String sFullURI)
Create a complete directory branch. |
boolean |
move(java.lang.String sSourceURI,
java.lang.String sTargetURI)
Move a file from one location to another |
void |
os(int iOperatingSystem)
|
java.lang.String |
password()
|
void |
password(java.lang.String sPassword)
|
protected java.lang.String |
path()
|
static char[] |
readfile(java.lang.String sFilePath)
Read a text file and returns a character array with it Enconding is UTF-8 by default |
static char[] |
readfile(java.lang.String sFilePath,
java.lang.String sCharSet)
Read a text file and returns a character array with it |
byte[] |
readfilebin(java.lang.String sFilePath)
Read a binary file into a byte array |
java.lang.Object |
readfileobj(java.lang.String sFilePath)
Read a serializable object from a text file |
java.lang.String |
readfilestr(java.lang.String sFilePath,
java.lang.String sEncoding)
Read a text file into a String |
java.lang.String |
realm()
|
boolean |
rename(java.lang.String sSourceURI,
java.lang.String sTargetURI)
Rename file |
boolean |
rmdir(java.lang.String sFullURI)
Remove a directory and all its subdirectories and files. |
protected void |
splitURI(java.lang.String sURI)
|
java.lang.String |
user()
|
void |
user(java.lang.String sUser)
|
void |
writefilebin(java.lang.String sFilePath,
byte[] aBytes)
Write a byte array to a text file |
void |
writefileobj(java.lang.String sFilePath,
java.io.Serializable oObj)
Write a serializable object to a text file |
void |
writefilestr(java.lang.String sFilePath,
java.lang.String sText,
java.lang.String sEncoding)
Write a String to a text file using given encoding |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String SLASH
public static final int OS_PUREJAVA
public static final int OS_UNIX
public static final int OS_WINDOWS
| Constructor Detail |
|---|
public FileSystem()
throws java.lang.NumberFormatException,
java.lang.IllegalArgumentException
Create new File System
Operation mode will be Pure Java by default
User and Password fro FTP access wil be readed from hipergate.cnf file
java.lang.NumberFormatException - If javamode property is not a positive integer number.
java.lang.IllegalArgumentException - If javamode property is not 0, 1 or 2.public FileSystem(int iMode)
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
iMode - Operation Mode { OS_PUREJAVA | OS_UNIX | OS_WINDOWS }
public FileSystem(java.lang.String sUser,
java.lang.String sPassword)
Create new File System
Operation mode will be Pure Java by default
sUser - User for FTP accesssPassword - Password for FTP access
public FileSystem(java.lang.String sUser,
java.lang.String sPassword,
java.lang.String sRealm)
Create new File System
Operation mode will be Pure Java by default
sUser - User for FTP accesssPassword - Password for FTP accesssRealm - Realm for HTTP authentication
public FileSystem(int iMode,
java.lang.String sUser,
java.lang.String sPassword)
Create new File System
iMode - Operation Mode: OS_PUREJAVA or OS_UNIX or OS_WINDOWSsUser - User for FTP accesssPassword - Password for FTP access
public FileSystem(java.util.Properties oProps)
throws java.lang.NumberFormatException,
java.lang.IllegalArgumentException
oProps - Properties collection.java.lang.NumberFormatException - If javamode property is not a positive integer number.
java.lang.IllegalArgumentException - If javamode property is not 0, 1 or 2.| Method Detail |
|---|
public void os(int iOperatingSystem)
iOperatingSystem - = { FileSystem.OS_PUREJAVA, FileSystem.OS_UNIX, FileSystem.OS_WINDOWS }public void user(java.lang.String sUser)
sUser - user for FTP accesspublic java.lang.String user()
public void password(java.lang.String sPassword)
sPassword - Password for FTP or HTTP accesspublic java.lang.String password()
public java.lang.String realm()
protected java.lang.String host()
protected java.lang.String path()
protected java.lang.String file()
protected void splitURI(java.lang.String sURI)
public boolean copy(java.lang.String sSourceURI,
java.lang.String sTargetURI)
throws java.net.MalformedURLException,
java.io.IOException,
java.lang.Exception
Copy a file
This method is able to copy a file from local or network disk location to and FTP location or viceversa.
sSourceURI - Source URI, it must have the following syntax:
protocol://[server:[port]]/path/filename
Even whe working with local files protocol must be specified, ej.
copy ("file:///tmp/upload/image.jpg", "file:///opt/storage/approved/image.jpg")sTargetURI - Target URI
java.lang.Exception
java.io.IOException
java.net.MalformedURLException
public boolean exists(java.lang.String sSourceURI)
throws java.io.IOException
sSouceURI - Source URI (including protocol preffix)
java.io.IOException
public int filelen(java.lang.String sFullURI)
throws java.io.IOException
Get file length
Currently only local and network files length can be queried
sFullURI - File URI (protocol+path)
java.io.IOException
public boolean rmdir(java.lang.String sFullURI)
throws java.io.IOException
sFullURI - Directory URI. For example: file:///tmp/upload
java.io.IOException
public boolean delete(java.lang.String sFullURI)
throws java.io.IOException
Delete o file or directory
Can recursively delete local or FTP directories
sFullURI - File or directory URI.
For example ftp://localhost/opt/temp/upload/logo.gif
java.io.IOException
public boolean delete(java.lang.String sFullURI,
java.lang.String sDeferedFiles)
throws java.io.IOException
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.
sFullURI - File URI to delete, ej. file:///opt/knowgate/files/deleteme.txtsDeferedFiles - Local path to file containing delete list
java.io.IOException
public boolean move(java.lang.String sSourceURI,
java.lang.String sTargetURI)
throws java.lang.Exception,
java.io.IOException
Move a file from one location to another
sSourceURI - Source URIsTargetURI - Target URI
java.lang.Exception
java.io.IOException
public boolean rename(java.lang.String sSourceURI,
java.lang.String sTargetURI)
throws java.lang.Exception,
java.io.IOException,
java.net.ProtocolException
sSourceURI - Source URI (ej. "file:///tmp/files/oldfile.txt")sTargetURI - Target URI (ej. "file:///tmp/files/newfile.txt")
java.lang.Exception
java.io.IOException
java.net.ProtocolException - If source and target file does not use the same protocol, either file:// or ftp://
public boolean mkdirs(java.lang.String sFullURI)
throws java.lang.Exception,
java.io.IOException
Create a complete directory branch.
sFullURI - Full path of directory to create,
ej. file:///tmp/uploads/binaries/images
ej. ftp://ftpserver/tmp/uploads/binaries/images
java.lang.Exception
java.io.IOException
public static void convert(java.lang.String sFilePath,
java.lang.String sOldCharset,
java.lang.String sNewCharset)
throws java.io.FileNotFoundException,
java.io.IOException,
java.io.UnsupportedEncodingException
Convert a text file from one character set to another
The input file is overwritten.
sFilePath - File PathsOldCharset - Original file character setsNewCharset - New character set
java.io.FileNotFoundException
java.io.IOException
java.io.UnsupportedEncodingException
public static java.lang.String detectEncoding(java.io.File oFile,
java.lang.String sDefault)
throws java.io.FileNotFoundException,
java.io.IOException
oFile - FilesDefault - String Character encoding to be returned if no clear character encoding was identified
java.io.FileNotFoundException
java.io.IOException
public java.lang.String detectEncoding(java.lang.String sFilePath,
java.lang.String sDefault)
throws java.io.FileNotFoundException,
java.io.IOException,
com.enterprisedt.net.ftp.FTPException
sFilePath - File Path including protocol. Like "file:///tmp/myfile.txt" or "ftp://myhost:21/dir/myfile.txt"sDefault - String Character encoding to be returned if no clear character encoding was identified
java.io.FileNotFoundException
java.io.IOException
com.enterprisedt.net.ftp.FTPException
public static char[] readfile(java.lang.String sFilePath)
throws java.io.FileNotFoundException,
java.io.IOException,
java.lang.OutOfMemoryError,
com.enterprisedt.net.ftp.FTPException
Read a text file and returns a character array with it
Enconding is UTF-8 by default
sFilePath - Full path of file to be readed. Like "file:///tmp/myfile.txt" or "ftp://myhost:21/dir/myfile.txt"
java.io.FileNotFoundException
java.io.IOException
java.lang.OutOfMemoryError
com.enterprisedt.net.ftp.FTPException
public static char[] readfile(java.lang.String sFilePath,
java.lang.String sCharSet)
throws java.io.FileNotFoundException,
java.io.IOException,
java.lang.OutOfMemoryError,
com.enterprisedt.net.ftp.FTPException
Read a text file and returns a character array with it
sFilePath - Full path of file to be readed. Like "file:///tmp/myfile.txt" or "ftp://myhost:21/dir/myfile.txt"sCharSet - Encoding character set name
java.io.FileNotFoundException
java.io.IOException
java.lang.OutOfMemoryError
com.enterprisedt.net.ftp.FTPException
public byte[] readfilebin(java.lang.String sFilePath)
throws java.net.MalformedURLException,
com.enterprisedt.net.ftp.FTPException,
java.io.FileNotFoundException,
java.io.IOException,
java.lang.OutOfMemoryError
Read a binary file into a byte array
sFilePath - Full path of file to be readed. Like "file:///tmp/myfile.txt" or "ftp://myhost:21/dir/myfile.txt"
java.io.FileNotFoundException
java.io.IOException
java.lang.OutOfMemoryError
java.net.MalformedURLException
com.enterprisedt.net.ftp.FTPException
public java.lang.String readfilestr(java.lang.String sFilePath,
java.lang.String sEncoding)
throws java.net.MalformedURLException,
com.enterprisedt.net.ftp.FTPException,
java.io.FileNotFoundException,
java.io.IOException,
java.lang.OutOfMemoryError
Read a text file into a String
sFilePath - Full path of file to be readed. Like "file:///tmp/myfile.txt" or "ftp://myhost:21/dir/myfile.txt"sEncoding - Text Encoding for file {UTF-8, ISO-8859-1, ...}java.io.FileNotFoundException
java.io.IOException
java.lang.OutOfMemoryError
java.net.MalformedURLException
com.enterprisedt.net.ftp.FTPException
public void writefilestr(java.lang.String sFilePath,
java.lang.String sText,
java.lang.String sEncoding)
throws java.io.IOException,
java.lang.OutOfMemoryError
sFilePath - Full file path. For example "file:///tmp/myfile.txt" or "ftp://localhost:21/tmp/myfile.txt"sText - String to be writtensEncoding - Encoding to be used
see Java Supported Encodings
java.io.IOException
java.lang.OutOfMemoryError
public void writefilebin(java.lang.String sFilePath,
byte[] aBytes)
throws java.io.IOException
sFilePath - Full file path. For example "file:///tmp/myfile.bin" or "ftp://localhost:21/tmp/myfile.bin"aBytes - Bytes to be written
java.io.IOException
public java.lang.Object readfileobj(java.lang.String sFilePath)
throws java.net.MalformedURLException,
java.io.FileNotFoundException,
java.io.IOException,
com.enterprisedt.net.ftp.FTPException,
java.lang.ClassNotFoundException
sFilePath - Full file path. For example "file:///tmp/myfile.bin" or "ftp://localhost:21/tmp/myfile.bin"
java.net.MalformedURLException - if sFilePath does not begin with file://or ftp://
java.lang.ClassNotFoundException
java.io.FileNotFoundException
java.io.IOException
com.enterprisedt.net.ftp.FTPException
public void writefileobj(java.lang.String sFilePath,
java.io.Serializable oObj)
throws java.io.IOException
sFilePath - Full file path. For example "file:///tmp/myfile.bin" or "ftp://localhost:21/tmp/myfile.bin"oObj - Serializable object to be written
java.io.IOException
public void downloadhtmlpage(java.lang.String sBasePath,
java.lang.String sFilePath,
java.io.OutputStream oOutStrm)
throws java.io.IOException
sBasePath - String Base path for page and its referenced filessFilePath - String File path from sBasePathoOutStrm - OutputStream where ZIP is written
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||