Java Doc for DefaultFileHandler.java in  » 6.0-JDK-Modules » j2me » com » sun » midp » io » j2me » file » 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 » 6.0 JDK Modules » j2me » com.sun.midp.io.j2me.file 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.sun.midp.io.j2me.file.DefaultFileHandler

DefaultFileHandler
class DefaultFileHandler implements BaseFileHandler(Code)
Default file handler.




Method Summary
native public  longavailableSize()
     Determines the free memory that is available on the file system the file or directory resides on.
native public  booleancanRead()
     Check is file corresponding to this filehandler exists and has a read permission.
native public  booleancanWrite()
     Check is file corresponding to this filehandler exists and has a write permission.
native public  voidclose()
     Close file associated with this handler.
native public  voidcloseForRead()
     Closes the file for reading.
native public  voidcloseForReadWrite()
     Closes the file for both reading and writing.
native public  voidcloseForWrite()
     Closes the file for writing.
public  voidconnect(String rootName, String fileName)
     Connect file handler to the abstract file target.
native public  voidcreate()
     Create file corresponding to this file handler.
public  voidcreatePrivateDir(String rootName)
     Creates dedicated private working directory for the MIDlet suite.
native public  voiddelete()
     Deletes the file or directory associated with this handler. The file or directory is deleted immediately on the actual file system upon invocation of this method.
native public  longdirectorySize(boolean includeSubDirs)
     Determines the size in bytes on a file system of all of the files that are contained in a directory.
Parameters:
  includeSubDirs - if true, size calculation willinclude all subdirectories' size.
native public  booleanexists()
     Check is file or directory corresponding to this filehandler exists.
native public  longfileSize()
     Determines the size of a file on the file system.
native public  voidflush()
     Flushes any output to the file.
native public static  chargetFileSeparator()
     Gets the system-dependent file separator character.
public  StringillegalFileNameChars()
     Returns a string that contains all characters forbidden for the use on the given platform except "/" (forward slash) which is always considered illegal.
native public  booleanisDirectory()
     Check is file corresponding to this filehandler exists and is a directory.
public  booleanisHidden()
     Check is file corresponding to this filehandler exists and is hidden.
native public  longlastModified()
     Returns the time that the file denoted by this file handler was last modified.
public  Vectorlist(String filter, boolean includeHidden)
     Gets a filtered list of files and directories contained in a directory. The directory is the handler's target as specified in create().
Parameters:
  filter - String against which all files and directories arematched for retrieval.
public  VectorlistRoots()
     List filesystem roots available on the device.
native public  voidmkdir()
     Creates a directory corresponding to the directory string provided in the connect() method. The directory is created immediately on the actual file system upon invocation of this method.
native public  voidopenForRead()
     Opens the file for reading.
native public  voidopenForWrite()
     Opens the file for writing.
native public  voidpositionForWrite(long offset)
     Sets the next write location.
native public  intread(byte b, int off, int len)
     Reads data from the file to an array.
public  voidrename(String newName)
     Renames the selected file or directory to a new name in the same directory.
public  voidsetHidden(boolean hidden)
     Sets the hidden attribute of the file associated with this file handler to the value provided.
native public  voidsetReadable(boolean readable)
     Sets the file or directory readable attribute to the indicated value.
native public  voidsetWritable(boolean writable)
     Sets the file or directory associated with this file handler writable attribute to the indicated value.
native public  longtotalSize()
     Determines the total size of the file system the connection's target resides on.
native public  voidtruncate(long byteOffset)
     Truncates the file, discarding all data from the given byte offset to the current end of the file.
public  longusedSize()
     Determines the used memory of a file system the connection's target resides on.
native public  intwrite(byte b, int off, int len)
     Write data from an array to the file.



Method Detail
availableSize
native public long availableSize()(Code)
Determines the free memory that is available on the file system the file or directory resides on. This may only be an estimate and may vary based on platform-specific file system blocking and metadata information. The available size in bytes on a file system, or -1 if anerror occurs.



canRead
native public boolean canRead()(Code)
Check is file corresponding to this filehandler exists and has a read permission. true if the file can be read



canWrite
native public boolean canWrite()(Code)
Check is file corresponding to this filehandler exists and has a write permission. true if the file can be written



close
native public void close() throws IOException(Code)
Close file associated with this handler. Open file and all system resources should be released by this call. Handler object can be reused by subsequent call to connect().
throws:
  IOException - if I/O error occurs



closeForRead
native public void closeForRead() throws IOException(Code)
Closes the file for reading.
throws:
  IOException - if any error occurs during input/output operations.



closeForReadWrite
native public void closeForReadWrite() throws IOException(Code)
Closes the file for both reading and writing.
throws:
  IOException - if any error occurs during input/output operations.



closeForWrite
native public void closeForWrite() throws IOException(Code)
Closes the file for writing.
throws:
  IOException - if any error occurs during input/output operations.



connect
public void connect(String rootName, String fileName)(Code)
Connect file handler to the abstract file target. This operation should not trigger any access to the native filesystem.
Parameters:
  rootName - The name of the root directory.
Parameters:
  fileName - Full path to the file to be handled by this handler.
throws:
  IllegalArgumentException - if filename contains charactersnot allowed by the file system. This check should not involveany actual access to the filesystem.



create
native public void create() throws IOException(Code)
Create file corresponding to this file handler. The file is created immediately on the actual file system upon invocation of this method. Files are created with zero length and data can be put into the file through write method after opening the file. This method does not create any directories specified in the file's path.
throws:
  IOException - if invoked on the existing file or unexpected erroroccurs.



createPrivateDir
public void createPrivateDir(String rootName) throws IOException(Code)
Creates dedicated private working directory for the MIDlet suite. Does nothing if specified root is not private root or the directory already exists.
Parameters:
  rootName - the name of file root



delete
native public void delete() throws IOException(Code)
Deletes the file or directory associated with this handler. The file or directory is deleted immediately on the actual file system upon invocation of this method. Previously open native file should be closed.The handler instance object remains connected and available for use.
throws:
  IOException - If the target is a directory and it is not empty,the connection target does not exist or is unaccessible, oran unspecified error occurs preventing deletion of the target.



directorySize
native public long directorySize(boolean includeSubDirs) throws IOException(Code)
Determines the size in bytes on a file system of all of the files that are contained in a directory.
Parameters:
  includeSubDirs - if true, size calculation willinclude all subdirectories' size. The size in bytes occupied by the files included in thedirectory, or -1 if the directory does not exist or isnot accessible.
throws:
  IOException - if some error occures while accessing the directory.



exists
native public boolean exists()(Code)
Check is file or directory corresponding to this filehandler exists. true if the file/directory exists,false otherwise.



fileSize
native public long fileSize() throws IOException(Code)
Determines the size of a file on the file system. The size of a file always represents the number of bytes contained in the file; there is no pre-allocated but empty space in a file. Users should perform an explicit flush() on any open output streams to the file prior to invoking this method to ensure accurate results. The size in bytes of the selected file, or -1 if thefile does not exist or is not accessible.
throws:
  IOException - if the method is invoked on a directory.



flush
native public void flush() throws IOException(Code)
Flushes any output to the file.
throws:
  IOException - if any error occurs.



getFileSeparator
native public static char getFileSeparator()(Code)
Gets the system-dependent file separator character. The file separator character.



illegalFileNameChars
public String illegalFileNameChars()(Code)
Returns a string that contains all characters forbidden for the use on the given platform except "/" (forward slash) which is always considered illegal. If there are no such characters an empty string is returned. string of illegal file name characters



isDirectory
native public boolean isDirectory()(Code)
Check is file corresponding to this filehandler exists and is a directory. true if pathname is a directory



isHidden
public boolean isHidden()(Code)
Check is file corresponding to this filehandler exists and is hidden. true if the file is not visible



lastModified
native public long lastModified()(Code)
Returns the time that the file denoted by this file handler was last modified. The time then last modification of the file took place.



list
public Vector list(String filter, boolean includeHidden) throws IOException(Code)
Gets a filtered list of files and directories contained in a directory. The directory is the handler's target as specified in create().
Parameters:
  filter - String against which all files and directories arematched for retrieval. An asterisk ("*") can be used as awildcard to represent 0 or more occurrences of any character.If null no filtering is performed
Parameters:
  includeHidden - boolean indicating whether files marked as hiddenshould be included or not in the list of files and directoriesreturned. An Enumeration of strings, denoting the files and directoriesin the directory matching the filter. Directories are denotedwith a trailing slash "/" in their returned name. TheEnumeration has zero length if the directory is empty or nofiles and/or directories are found matching the given filter.Any current directory indication (".") and any parent directoryindication ("..") is not included in the list of files anddirectories returned.
throws:
  IOException - if invoked on a file, the directory does not exist,the directory is not accessible, or an I/O error occurs.
throws:
  IllegalArgumentException - if filter contains any pathspecification or is an invalid filename for the platform(e.g. contains characters invalid for a filename on theirplatform).



listRoots
public Vector listRoots()(Code)
List filesystem roots available on the device. For the description of the correct root format see FileConnection documentation. array of roots;empty array is returned if there are no roots available.



mkdir
native public void mkdir() throws IOException(Code)
Creates a directory corresponding to the directory string provided in the connect() method. The directory is created immediately on the actual file system upon invocation of this method. Directories in the specified path are not recursively created and must be explicitly created before subdirectories can be created.
throws:
  IOException - if invoked on an existing directory or on any file(create() is used to create files), the targetfile system is not accessible, or an unspecified error occurspreventing creation of the directory.



openForRead
native public void openForRead() throws IOException(Code)
Opens the file for reading.
throws:
  IOException - if any error occurs during input/output operations.



openForWrite
native public void openForWrite() throws IOException(Code)
Opens the file for writing.
throws:
  IOException - if any error occurs during input/output operations.



positionForWrite
native public void positionForWrite(long offset) throws IOException(Code)
Sets the next write location.
Parameters:
  offset - seek position for next write
throws:
  IOException - if any error occurs.



read
native public int read(byte b, int off, int len) throws IOException(Code)
Reads data from the file to an array.
Parameters:
  b - array for input data
Parameters:
  off - index in the input array
Parameters:
  len - length of data to read length of data really read
throws:
  IOException - if any error occurs.



rename
public void rename(String newName) throws IOException(Code)
Renames the selected file or directory to a new name in the same directory. The file or directory is renamed immediately on the actual file system upon invocation of this method. No file or directory by the original name exists after this method call. Previously open native file should be closed. The handler instance object remains connected and available for use, referring now to the file or directory by its new name.
Parameters:
  newName - The new name of the file or directory. The name mustbe the full qualified name of the new file
throws:
  IOException - if the connection's target does not exist, theconnection's target is not accessible, a file or directoryalready exists by the newName, ornewName is an invalid filename for the platform(e.g. contains characters invalid in a filenameon the platform).



setHidden
public void setHidden(boolean hidden) throws IOException(Code)
Sets the hidden attribute of the file associated with this file handler to the value provided. The attribute is applied to the file on the actual file system immediately upon invocation of this method if the file system and platform support it. If the file system doesn't support a hidden attribute, this method is ignored and isHidden() always returns false. Since the exact definition of hidden is system-dependent, this method only works on file systems that support a settable file attribute. For example, on Win32 and FAT file systems, a file may be considered hidden if it has been marked as such in the file's attributes; therefore this method is applicable. However on UNIX systems a file may be considered to be hidden if its name begins with a period character ('.'). In the UNIX case, this method may be ignored and the method to make a file hidden may be the rename() method.
Parameters:
  hidden - The new state of the hidden flag of the selected file.
throws:
  IOException - if the connection's target does not exist or is notaccessible.
See Also:   DefaultFileHandler.isHidden



setReadable
native public void setReadable(boolean readable) throws IOException(Code)
Sets the file or directory readable attribute to the indicated value. The readable attribute for the file on the actual file system is set immediately upon invocation of this method. If the file system doesn't support a settable read attribute, this method is ignored and canRead() always returns true.
Parameters:
  readable - The new state of the readable flag ofthe selected file.
throws:
  IOException - of the connection's target does not exist or is notaccessible.
See Also:   DefaultFileHandler.canRead



setWritable
native public void setWritable(boolean writable) throws IOException(Code)
Sets the file or directory associated with this file handler writable attribute to the indicated value. The writable attribute for the file on the actual file system is set immediately upon invocation of the method. If the file system doesn't support a settable write attribute, this method is ignored and canWrite() always returns true.
Parameters:
  writable - The new state of the writable flag of the selectedfile.
throws:
  IOException - if the connection's target does not exist or is notaccessible.
See Also:   DefaultFileHandler.canWrite



totalSize
native public long totalSize()(Code)
Determines the total size of the file system the connection's target resides on. The total size of the file system in bytes, or -1 if anerror occurs.



truncate
native public void truncate(long byteOffset) throws IOException(Code)
Truncates the file, discarding all data from the given byte offset to the current end of the file. If the byte offset provided is greater than or equal to the file's current byte count, the method returns without changing the file.
Parameters:
  byteOffset - the offset into the file from which truncationoccurs.
throws:
  IOException - if invoked on a directory or the file does notexist or is not accessible.



usedSize
public long usedSize()(Code)
Determines the used memory of a file system the connection's target resides on. This may only be an estimate and may vary based on platform-specific file system blocking and metadata information. The used size of bytes on a file system, or -1 if anerror occurs.



write
native public int write(byte b, int off, int len) throws IOException(Code)
Write data from an array to the file.
Parameters:
  b - array of output data
Parameters:
  off - index in the output array
Parameters:
  len - length of data to write length of data really written
throws:
  IOException - if any error occurs.



Methods inherited from java.lang.Object
public boolean equals(Object obj)(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.