Java Doc for FileSystem.java in  » Groupware » hipergate » com » knowgate » dfs » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » com.knowgate.dfs 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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


Field Summary
final public static  intOS_PUREJAVA
    
final public static  intOS_UNIX
    
final public static  intOS_WINDOWS
    
protected  StringSLASH
    

Constructor Summary
public  FileSystem()
    
public  FileSystem(int iMode)
    
public  FileSystem(String sUser, String sPassword)
    
public  FileSystem(int iMode, String sUser, String sPassword)
    
public  FileSystem(Properties oProps)
    

Method Summary
public static  voidconvert(String sFilePath, String sOldCharset, String sNewCharset)
    

Convert a text file from one character set to another

The input file is overwritten.
public  booleancopy(String sSourceURI, String sTargetURI)
    
public  booleandelete(String sFullURI)
    
public  booleandelete(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  StringdetectEncoding(File oFile, String sDefault)
    
public  StringdetectEncoding(String sFilePath, String sDefault)
    
protected  Stringfile()
    
public  intfilelen(String sFullURI)
    
protected  Stringhost()
    
public  booleanmkdirs(String sFullURI)
    

Create a complete directory branch.


Parameters:
  sFullURI - Full path of directory to create,ej.
public  booleanmove(String sSourceURI, String sTargetURI)
    
public  voidos(int iOperatingSystem)
    
public  voidpassword(String sPassword)
    
public  Stringpassword()
    
protected  Stringpath()
    
public static  char[]readfile(String sFilePath)
    
public static  char[]readfile(String sFilePath, String sCharSet)
    
public  byte[]readfilebin(String sFilePath)
    
public  Stringreadfilestr(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  booleanrename(String sSourceURI, String sTargetURI)
     Rename file
Parameters:
  sSourceURI - Source URI (ej.
public  booleanrmdir(String sFullURI)
     Remove a directory and all its subdirectories and files.
Parameters:
  sFullURI - Directory URI.
protected  voidsplitURI(String sURI)
    
public  voiduser(String sUser)
    
public  Stringuser()
    
public  voidwritefilebin(String sFilePath, byte[] aBytes)
     Write a byte array to a text file
Parameters:
  sFilePath - Full file path.
public  voidwritefilestr(String sFilePath, String sText, String sEncoding)
     Write a String to a text file using given encoding
Parameters:
  sFilePath - Full file path.

Field Detail
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)



SLASH
protected String SLASH(Code)




Constructor Detail
FileSystem
public FileSystem() throws NumberFormatException, IllegalArgumentException(Code)

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


throws:
  NumberFormatException - If javamode property is not a positive integer number.
throws:
  IllegalArgumentException - If javamode property is not 0, 1 or 2.



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



FileSystem
public FileSystem(Properties oProps) throws NumberFormatException, IllegalArgumentException(Code)

Parameters:
  oProps - Properties collection.
Property names:
javamode : "0" (default) for Pure Java, "1" for UNIX, "2" for Windows.
fileuser : User for FTP access (default is "anonymous").filepassword : Password for FTP access (default is "").
throws:
  NumberFormatException - If javamode property is not a positive integer number.
throws:
  IllegalArgumentException - If javamode property is not 0, 1 or 2.




Method Detail
convert
public static void convert(String sFilePath, String sOldCharset, String sNewCharset) throws FileNotFoundException, IOException, UnsupportedEncodingException(Code)

Convert a text file from one character set to another

The input file is overwritten.
Parameters:
  sFilePath - File Path
Parameters:
  sOldCharset - Original file character set
Parameters:
  sNewCharset - New character set
throws:
  FileNotFoundException -
throws:
  IOException -
throws:
  UnsupportedEncodingException -



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 -



detectEncoding
public static String detectEncoding(File oFile, String sDefault) throws FileNotFoundException, IOException(Code)
Detect file encoding by reading its first three bytes
Parameters:
  oFile - File
Parameters:
  sDefault - String Character encoding to be returned if no clear character encoding was identified String UTF-16LE, UTF-16BE or UTF-8
throws:
  FileNotFoundException -
throws:
  IOException -
since:
   3.1



detectEncoding
public String detectEncoding(String sFilePath, String sDefault) throws FileNotFoundException, IOException, FTPException(Code)
Detect file encoding by reading its first three bytes
Parameters:
  sFilePath - File Path
Parameters:
  sDefault - String Character encoding to be returned if no clear character encoding was identified String UTF-16LE, UTF-16BE or UTF-8
throws:
  FileNotFoundException -
throws:
  IOException -
since:
   3.1



file
protected String file()(Code)



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 -



host
protected String host()(Code)



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 -



move
public boolean move(String sSourceURI, String sTargetURI) throws Exception, IOException(Code)

Move a file from one location to another


Parameters:
  sSourceURI - Source URI
Parameters:
  sTargetURI - Target URI
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



path
protected String path()(Code)



readfile
public static char[] readfile(String sFilePath) throws FileNotFoundException, IOException, OutOfMemoryError, FTPException(Code)

Read a text file and returns a character array with it

Enconding is UTF-8 by default
Parameters:
  sFilePath - Full path of file to be readed character array with full contents of file
throws:
  FileNotFoundException -
throws:
  IOException -
throws:
  OutOfMemoryError -
throws:
  FTPException -



readfile
public static char[] readfile(String sFilePath, String sCharSet) throws FileNotFoundException, IOException, OutOfMemoryError, FTPException(Code)

Read a text file and returns a character array with it


Parameters:
  sFilePath - Full path of file to be readed
Parameters:
  sCharSet - Encoding character set name character array with full contents of file
throws:
  FileNotFoundException -
throws:
  IOException -
throws:
  OutOfMemoryError -
throws:
  FTPException -



readfilebin
public byte[] readfilebin(String sFilePath) throws MalformedURLException, FTPException, FileNotFoundException, IOException, OutOfMemoryError(Code)

Read a binary file into a byte array


Parameters:
  sFilePath - Full path of file to be readed byte array with full contents of file
throws:
  FileNotFoundException -
throws:
  IOException -
throws:
  OutOfMemoryError -
throws:
  MalformedURLException -
throws:
  FTPException -



readfilestr
public String readfilestr(String sFilePath, String sEncoding) throws MalformedURLException, FTPException, FileNotFoundException, IOException, OutOfMemoryError(Code)

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. String with full contents of file
throws:
  FileNotFoundException -
throws:
  IOException -
throws:
  OutOfMemoryError -
throws:
  MalformedURLException -
throws:
  FTPException -



rename
public boolean rename(String sSourceURI, String sTargetURI) throws Exception, IOException, ProtocolException(Code)
Rename file
Parameters:
  sSourceURI - Source URI (ej. "file:///tmp/files/oldfile.txt")
Parameters:
  sTargetURI - Target URI (ej. "file:///tmp/files/newfile.txt")
since:
   2.1
throws:
  Exception -
throws:
  IOException -
throws:
  ProtocolException - If source and target file does not use the same protocol, either file:// or ftp://



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 -



splitURI
protected void splitURI(String sURI)(Code)



user
public void user(String sUser)(Code)

Parameters:
  sUser - user for FTP access



user
public String user()(Code)
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



writefilestr
public void writefilestr(String sFilePath, String sText, String sEncoding) throws IOException, OutOfMemoryError(Code)
Write a String to a text file using given encoding
Parameters:
  sFilePath - Full file path. For example "file:///tmp/myfile.txt" or "ftp://localhost:21/tmp/myfile.txt"
Parameters:
  sText - String to be written
Parameters:
  sEncoding - Encoding to be usedsee Java Supported Encodings
throws:
  IOException -
throws:
  OutOfMemoryError -



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.