Java Doc for SmbFile.java in  » Net » jCIFS » jcifs » smb » 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 » Net » jCIFS » jcifs.smb 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.net.URLConnection
      jcifs.smb.SmbFile

All known Subclasses:   jcifs.smb.SmbNamedPipe,
SmbFile
public class SmbFile extends URLConnection (Code)
This class represents a resource on an SMB network. Mainly these resources are files and directories however an SmbFile may also refer to servers and workgroups. If the resource is a file or directory the methods of SmbFile follow the behavior of the well known java.io.File class. One fundamental difference is the usage of a URL scheme [1] to specify the target file or directory. SmbFile URLs have the following syntax:
 smb://[[[domain;]username[:password]@]server[:port]/[[share/[dir/]file]]][?[param=value[param2=value2[...]]]
 
This example:
 smb://storage15/public/foo.txt
 
would reference the file foo.txt in the share public on the server storage15. In addition to referencing files and directories, jCIFS can also address servers, and workgroups.

Important: all SMB URLs that represent workgroups, servers, shares, or directories require a trailing slash '/'.

When using the java.net.URL class with 'smb://' URLs it is necessary to first call the static jcifs.Config.registerSmbURLHandler(); method. This is required to register the SMB protocol handler.

The userinfo component of the SMB URL (domain;user:pass) must be URL encoded if it contains reserved characters. According to RFC 2396 these characters are non US-ASCII characters and most meta characters however jCIFS will work correctly with anything but '@' which is used to delimit the userinfo component from the server and '%' which is the URL escape character itself.

The server component may a traditional NetBIOS name, a DNS name, or IP address. These name resolution mechanisms and their resolution order can be changed (See Setting Name Resolution Properties). The servername and path components are not case sensitive but the domain, username, and password components are. It is also likely that properties must be specified for jcifs to function (See Setting JCIFS Properties). Here are some examples of SMB URLs with brief descriptions of what they do:

[1] This URL scheme is based largely on the SMB Filesharing URL Scheme IETF draft.

SMB URL Examples
URLDescription
smb://users-nyc;miallen:mypass@angus/tmp/ This URL references a share called tmp on the server angus as user miallen who's password is mypass.
smb://Administrator:P%40ss@msmith1/c/WINDOWS/Desktop/foo.txt A relativly sophisticated example that references a file msmith1's desktop as user Administrator. Notice the '@' is URL encoded with the '%40' hexcode escape.
smb://angus/ This references only a server. The behavior of some methods is different in this context(e.g. you cannot delete a server) however as you might expect the list method will list the available shares on this server.
smb://myworkgroup/ This syntactically is identical to the above example. However if myworkgroup happends to be a workgroup(which is indeed suggested by the name) the list method will return a list of servers that have registered themselves as members of myworkgroup.
smb:// Just as smb://server/ lists shares and smb://workgroup/ lists servers, the smb:// URL lists all available workgroups on a netbios LAN. Again, in this context many methods are not valid and return default values(e.g. isHidden and renameTo will always return false).
smb://angus.foo.net/d/jcifs/pipes.doc The server name may also be a DNS name as it is in this example. See Setting Name Resolution Properties for details.
smb://192.168.1.15/ADMIN$/ The server name may also be an IP address. See Setting Name Resolution Properties for details.
smb://domain;username:password@server/share/path/to/file.txt A prototypical example that uses all the fields.
smb://myworkgroup/angus/ <-- ILLEGAL Despite the hierarchial relationship between workgroups, servers, and filesystems this example is not valid.
smb://server/share/path/to/dir <-- ILLEGAL URLs that represent workgroups, servers, shares, or directories require a trailing slash '/'.
smb://MYGROUP/?SERVER=192.168.10.15 SMB URLs support some query string parameters. In this example the SERVER parameter is used to override the server name service lookup to contact the server 192.168.10.15 (presumably known to be a master browser) for the server list in workgroup MYGROUP.

A second constructor argument may be specified to augment the URL for better programmatic control when processing many files under a common base. This is slightly different from the corresponding java.io.File usage; a '/' at the beginning of the second parameter will still use the server component of the first parameter. The examples below illustrate the resulting URLs when this second contructor argument is used.

Examples Of SMB URLs When Augmented With A Second Constructor Parameter
First ParameterSecond ParameterResult
smb://host/share/a/b/ c/d/ smb://host/share/a/b/c/d/
smb://host/share/foo/bar/ /share2/zig/zag smb://host/share2/zig/zag
smb://host/share/foo/bar/ ../zip/ smb://host/share/foo/zip/
smb://host/share/zig/zag smb://foo/bar/ smb://foo/bar/
smb://host/share/foo/ ../.././.././../foo/ smb://host/foo/
smb://host/share/zig/zag / smb://host/
smb://server/ ../ smb://server/
smb:// myworkgroup/ smb://myworkgroup/
smb://myworkgroup/ angus/ smb://myworkgroup/angus/ <-- ILLEGAL
(But if you first create an SmbFile with 'smb://workgroup/' and use and use it as the first parameter to a constructor that accepts it with a second String parameter jCIFS will factor out the 'workgroup'.)

Instances of the SmbFile class are immutable; that is, once created, the abstract pathname represented by an SmbFile object will never change.
See Also:   java.io.File


Inner Class :class WriterThread extends Thread

Field Summary
final public static  intATTR_ARCHIVE
    
final static  intATTR_COMPRESSED
    
final public static  intATTR_DIRECTORY
    
final static  intATTR_GET_MASK
    
final public static  intATTR_HIDDEN
    
final static  intATTR_NORMAL
    
final public static  intATTR_READONLY
    
final static  intATTR_SET_MASK
    
final public static  intATTR_SYSTEM
    
final static  intATTR_TEMPORARY
    
final public static  intATTR_VOLUME
    
final static  intDEFAULT_ATTR_EXPIRATION_PERIOD
    
final public static  intFILE_NO_SHARE
     When specified as the shareAccess constructor parameter, other SMB clients (including other threads making calls into jCIFS) will not be permitted to access the target file and will receive "The file is being accessed by another process" message.
final public static  intFILE_SHARE_DELETE
     When specified as the shareAccess constructor parameter, other SMB clients will be permitted to delete the target file while this file is open.
final public static  intFILE_SHARE_READ
     When specified as the shareAccess constructor parameter, other SMB clients will be permitted to read from the target file while this file is open.
final public static  intFILE_SHARE_WRITE
     When specified as the shareAccess constructor parameter, other SMB clients will be permitted to write to the target file while this file is open.
final static  intHASH_DOT
    
final static  intHASH_DOT_DOT
    
final static  intO_APPEND
    
final static  intO_CREAT
    
final static  intO_EXCL
    
final static  intO_RDONLY
    
final static  intO_RDWR
    
final static  intO_TRUNC
    
final static  intO_WRONLY
    
final public static  intTYPE_COMM
     Returned by SmbFile.getType() if the resource this SmbFile represents is a communications device.
final public static  intTYPE_FILESYSTEM
     Returned by SmbFile.getType() if the resource this SmbFile represents is a regular file or directory.
final public static  intTYPE_NAMED_PIPE
     Returned by SmbFile.getType() if the resource this SmbFile represents is a named pipe.
final public static  intTYPE_PRINTER
     Returned by SmbFile.getType() if the resource this SmbFile represents is a printer.
final public static  intTYPE_SERVER
     Returned by SmbFile.getType() if the resource this SmbFile represents is a server.
final public static  intTYPE_SHARE
     Returned by SmbFile.getType() if the resource this SmbFile represents is a share.
final public static  intTYPE_WORKGROUP
     Returned by SmbFile.getType() if the resource this SmbFile represents is a workgroup.
static  longattrExpirationPeriod
    
 intfid
    
static  LogStreamlog
    
 booleanopened
    
 SmbTreetree
    
 inttype
    
 Stringunc
    

Constructor Summary
public  SmbFile(String url)
     Constructs an SmbFile representing a resource on an SMB network such as a file or directory.
public  SmbFile(SmbFile context, String name)
     Constructs an SmbFile representing a resource on an SMB network such as a file or directory.
public  SmbFile(String context, String name)
     Constructs an SmbFile representing a resource on an SMB network such as a file or directory.
public  SmbFile(String url, NtlmPasswordAuthentication auth)
     Constructs an SmbFile representing a resource on an SMB network such as a file or directory.
public  SmbFile(String url, NtlmPasswordAuthentication auth, int shareAccess)
     Constructs an SmbFile representing a file on an SMB network.
public  SmbFile(String context, String name, NtlmPasswordAuthentication auth)
     Constructs an SmbFile representing a resource on an SMB network such as a file or directory.
public  SmbFile(String context, String name, NtlmPasswordAuthentication auth, int shareAccess)
     Constructs an SmbFile representing a resource on an SMB network such as a file or directory.
public  SmbFile(SmbFile context, String name, int shareAccess)
     Constructs an SmbFile representing a resource on an SMB network such as a file or directory.
public  SmbFile(URL url)
     Constructs an SmbFile representing a resource on an SMB network such as a file or directory from a URL object.
public  SmbFile(URL url, NtlmPasswordAuthentication auth)
     Constructs an SmbFile representing a resource on an SMB network such as a file or directory from a URL object and an NtlmPasswordAuthentication object.
 SmbFile(SmbFile context, String name, int type, int attributes, long createTime, long lastModified, long size)
    

Method Summary
public  booleancanRead()
     Tests to see if the file this SmbFile represents can be read.
public  booleancanWrite()
     Tests to see if the file this SmbFile represents exists and is not marked read-only.
 voidclose(int f, long lastWriteTime)
    
 voidclose(long lastWriteTime)
    
 voidclose()
    
public  voidconnect()
     It is not necessary to call this method directly.
 voidconnect0()
    
public  voidcopyTo(SmbFile dest)
     This method will copy the file or directory represented by this SmbFile and it's sub-contents to the location specified by the dest parameter.
 voidcopyTo0(SmbFile dest, byte[][] b, int bsize, WriterThread w, SmbComReadAndX req, SmbComReadAndXResponse resp)
    
public  voidcreateNewFile()
     Create a new file but fail if it already exists.
public  longcreateTime()
     Retrieve the time this SmbFile was created.
public  voiddelete()
     This method will delete the file or directory specified by this SmbFile.
 voiddelete(String fileName)
    
 voiddoFindFirstNext(ArrayList list, boolean files, String wildcard, int searchAttributes, SmbFilenameFilter fnf, SmbFileFilter ff)
    
 voiddoNetEnum(ArrayList list, boolean files, String wildcard, int searchAttributes, SmbFilenameFilter fnf, SmbFileFilter ff)
    
public  booleanequals(Object obj)
     Tests to see if two SmbFile objects are equal.
public  booleanexists()
     Tests to see if the SMB resource exists.
 UniAddressgetAddress()
    
public  intgetAttributes()
     Return the attributes of this file.
public  StringgetCanonicalPath()
     Returns the full URL of this SMB resource with '.' and '..' components factored out.
public  intgetContentLength()
     This URLConnection method just returns the result of length().
public  longgetDate()
     This URLConnection method just returns the result of lastModified.
public  StringgetDfsPath()
     If the path of this SmbFile falls within a DFS volume, this method will return the referral path to which it maps.
public  longgetDiskFreeSpace()
     This method returns the free disk space in bytes of the drive this share represents or the drive on which the directory or file resides.
public  InputStreamgetInputStream()
     This URLConnection method just returns a new SmbFileInputStream created with this file.
public  longgetLastModified()
     This URLConnection method just returns the result of lastModified.
public  StringgetName()
     Returns the last component of the target URL.
public  OutputStreamgetOutputStream()
     This URLConnection method just returns a new SmbFileOutputStream created with this file.
public  StringgetParent()
     Everything but the last component of the URL representing this SMB resource is effectivly it's parent.
public  StringgetPath()
     Returns the full uncanonicalized URL of this SMB resource.
public  PrincipalgetPrincipal()
     Returns the NtlmPasswordAuthentication object used as credentials with this file or pipe.
public  StringgetServer()
     Retrieve the hostname of the server for this SMB resource.
public  StringgetShare()
     Retrieves the share associated with this SMB resource.
public  intgetType()
     Returns type of of object this SmbFile represents.
public  StringgetUncPath()
     Retuns the Windows UNC style path with backslashs intead of forward slashes.
 StringgetUncPath0()
    
public  inthashCode()
     Computes a hashCode for this file based on the URL string and IP address if the server.
 booleanisConnected()
    
public  booleanisDirectory()
     Tests to see if the file this SmbFile represents is a directory.
public  booleanisFile()
     Tests to see if the file this SmbFile represents is not a directory.
public  booleanisHidden()
     Tests to see if the file this SmbFile represents is marked as hidden.
 booleanisOpen()
    
 booleanisWorkgroup0()
    
public  longlastModified()
     Retrieve the last time the file represented by this SmbFile was modified.
public  longlength()
     Returns the length of this SmbFile in bytes.
public  String[]list()
     List the contents of this SMB resource.
public  String[]list(SmbFilenameFilter filter)
     List the contents of this SMB resource.
 String[]list(String wildcard, int searchAttributes, SmbFilenameFilter fnf, SmbFileFilter ff)
    
public  SmbFile[]listFiles()
     List the contents of this SMB resource as an array of SmbFile objects.
public  SmbFile[]listFiles(String wildcard)
     The CIFS protocol provides for DOS "wildcards" to be used as a performance enhancement.
public  SmbFile[]listFiles(SmbFilenameFilter filter)
     List the contents of this SMB resource.
public  SmbFile[]listFiles(SmbFileFilter filter)
     List the contents of this SMB resource.
 SmbFile[]listFiles(String wildcard, int searchAttributes, SmbFilenameFilter fnf, SmbFileFilter ff)
    
public  voidmkdir()
     Creates a directory with the path specified by this SmbFile.
public  voidmkdirs()
     Creates a directory with the path specified by this SmbFile and any parent directories that do not exist.
 voidopen(int flags, int attrs, int options)
    
 intopen0(int flags, int attrs, int options)
    
static  StringqueryLookup(String query, String param)
    
 InfoqueryPath(String path, int infoLevel)
    
public  voidrenameTo(SmbFile dest)
     Changes the name of the file this SmbFile represents to the name designated by the SmbFile argument.

Remember: SmbFiles are immutible and therefore the path associated with this SmbFile object will not change).

 voidsend(ServerMessageBlock request, ServerMessageBlock response)
    
 voidsendTransaction(SmbComTransaction request, SmbComTransactionResponse response)
    
public  voidsetAttributes(int attrs)
     Set the attributes of this file.
public  voidsetCreateTime(long time)
     Set the create time of the file.
public  voidsetLastModified(long time)
     Set the last modified time of the file.
 voidsetPathInformation(int attrs, long ctime, long mtime)
    
public  voidsetReadOnly()
     Make this file read-only.
public  voidsetReadWrite()
     Turn off the read-only attribute of this file.
public  StringtoString()
     Returns the string representation of this SmbFile object.
public  URLtoURL()
     Returns a java.net.URL for this SmbFile.

Field Detail
ATTR_ARCHIVE
final public static int ATTR_ARCHIVE(Code)
A file with this bit on as returned by getAttributes() or set with setAttributes() is an archived file



ATTR_COMPRESSED
final static int ATTR_COMPRESSED(Code)



ATTR_DIRECTORY
final public static int ATTR_DIRECTORY(Code)
A file with this bit on as returned by getAttributes() is a directory



ATTR_GET_MASK
final static int ATTR_GET_MASK(Code)



ATTR_HIDDEN
final public static int ATTR_HIDDEN(Code)
A file with this bit on as returned by getAttributes() or set with setAttributes() will be hidden



ATTR_NORMAL
final static int ATTR_NORMAL(Code)



ATTR_READONLY
final public static int ATTR_READONLY(Code)
A file with this bit on as returned by getAttributes() or set with setAttributes() will be read-only



ATTR_SET_MASK
final static int ATTR_SET_MASK(Code)



ATTR_SYSTEM
final public static int ATTR_SYSTEM(Code)
A file with this bit on as returned by getAttributes() or set with setAttributes() will be a system file



ATTR_TEMPORARY
final static int ATTR_TEMPORARY(Code)



ATTR_VOLUME
final public static int ATTR_VOLUME(Code)
A file with this bit on as returned by getAttributes() is a volume



DEFAULT_ATTR_EXPIRATION_PERIOD
final static int DEFAULT_ATTR_EXPIRATION_PERIOD(Code)



FILE_NO_SHARE
final public static int FILE_NO_SHARE(Code)
When specified as the shareAccess constructor parameter, other SMB clients (including other threads making calls into jCIFS) will not be permitted to access the target file and will receive "The file is being accessed by another process" message.



FILE_SHARE_DELETE
final public static int FILE_SHARE_DELETE(Code)
When specified as the shareAccess constructor parameter, other SMB clients will be permitted to delete the target file while this file is open. This constant may be logically OR'd with other share access flags.



FILE_SHARE_READ
final public static int FILE_SHARE_READ(Code)
When specified as the shareAccess constructor parameter, other SMB clients will be permitted to read from the target file while this file is open. This constant may be logically OR'd with other share access flags.



FILE_SHARE_WRITE
final public static int FILE_SHARE_WRITE(Code)
When specified as the shareAccess constructor parameter, other SMB clients will be permitted to write to the target file while this file is open. This constant may be logically OR'd with other share access flags.



HASH_DOT
final static int HASH_DOT(Code)



HASH_DOT_DOT
final static int HASH_DOT_DOT(Code)



O_APPEND
final static int O_APPEND(Code)



O_CREAT
final static int O_CREAT(Code)



O_EXCL
final static int O_EXCL(Code)



O_RDONLY
final static int O_RDONLY(Code)



O_RDWR
final static int O_RDWR(Code)



O_TRUNC
final static int O_TRUNC(Code)



O_WRONLY
final static int O_WRONLY(Code)



TYPE_COMM
final public static int TYPE_COMM(Code)
Returned by SmbFile.getType() if the resource this SmbFile represents is a communications device.



TYPE_FILESYSTEM
final public static int TYPE_FILESYSTEM(Code)
Returned by SmbFile.getType() if the resource this SmbFile represents is a regular file or directory.



TYPE_NAMED_PIPE
final public static int TYPE_NAMED_PIPE(Code)
Returned by SmbFile.getType() if the resource this SmbFile represents is a named pipe.



TYPE_PRINTER
final public static int TYPE_PRINTER(Code)
Returned by SmbFile.getType() if the resource this SmbFile represents is a printer.



TYPE_SERVER
final public static int TYPE_SERVER(Code)
Returned by SmbFile.getType() if the resource this SmbFile represents is a server.



TYPE_SHARE
final public static int TYPE_SHARE(Code)
Returned by SmbFile.getType() if the resource this SmbFile represents is a share.



TYPE_WORKGROUP
final public static int TYPE_WORKGROUP(Code)
Returned by SmbFile.getType() if the resource this SmbFile represents is a workgroup.



attrExpirationPeriod
static long attrExpirationPeriod(Code)



fid
int fid(Code)



log
static LogStream log(Code)



opened
boolean opened(Code)



tree
SmbTree tree(Code)



type
int type(Code)



unc
String unc(Code)




Constructor Detail
SmbFile
public SmbFile(String url) throws MalformedURLException(Code)
Constructs an SmbFile representing a resource on an SMB network such as a file or directory. See the description and examples of smb URLs above.
Parameters:
  url - A URL string
throws:
  MalformedURLException - If the parent and child parametersdo not follow the prescribed syntax



SmbFile
public SmbFile(SmbFile context, String name) throws MalformedURLException, UnknownHostException(Code)
Constructs an SmbFile representing a resource on an SMB network such as a file or directory. The second parameter is a relative path from the parent SmbFile. See the description above for examples of using the second name parameter.
Parameters:
  context - A base SmbFile
Parameters:
  name - A path string relative to the parent paremeter
throws:
  MalformedURLException - If the parent and child parametersdo not follow the prescribed syntax
throws:
  UnknownHostException - If the server or workgroup of the context file cannot be determined



SmbFile
public SmbFile(String context, String name) throws MalformedURLException(Code)
Constructs an SmbFile representing a resource on an SMB network such as a file or directory. The second parameter is a relative path from the parent. See the description above for examples of using the second chile parameter.
Parameters:
  context - A URL string
Parameters:
  name - A path string relative to the context paremeter
throws:
  MalformedURLException - If the context and name parametersdo not follow the prescribed syntax



SmbFile
public SmbFile(String url, NtlmPasswordAuthentication auth) throws MalformedURLException(Code)
Constructs an SmbFile representing a resource on an SMB network such as a file or directory.
Parameters:
  url - A URL string
Parameters:
  auth - The credentials the client should use for authentication
throws:
  MalformedURLException - If the url parameter does not follow the prescribed syntax



SmbFile
public SmbFile(String url, NtlmPasswordAuthentication auth, int shareAccess) throws MalformedURLException(Code)
Constructs an SmbFile representing a file on an SMB network. The shareAccess parameter controls what permissions other clients have when trying to access the same file while this instance is still open. This value is either FILE_NO_SHARE or any combination of FILE_SHARE_READ, FILE_SHARE_WRITE, and FILE_SHARE_DELETE logically OR'd together.
Parameters:
  url - A URL string
Parameters:
  auth - The credentials the client should use for authentication
Parameters:
  shareAccess - Specifies what access other clients have while this file is open.
throws:
  MalformedURLException - If the url parameter does not follow the prescribed syntax



SmbFile
public SmbFile(String context, String name, NtlmPasswordAuthentication auth) throws MalformedURLException(Code)
Constructs an SmbFile representing a resource on an SMB network such as a file or directory. The second parameter is a relative path from the context. See the description above for examples of using the second name parameter.
Parameters:
  context - A URL string
Parameters:
  name - A path string relative to the context paremeter
Parameters:
  auth - The credentials the client should use for authentication
throws:
  MalformedURLException - If the context and name parametersdo not follow the prescribed syntax



SmbFile
public SmbFile(String context, String name, NtlmPasswordAuthentication auth, int shareAccess) throws MalformedURLException(Code)
Constructs an SmbFile representing a resource on an SMB network such as a file or directory. The second parameter is a relative path from the context. See the description above for examples of using the second name parameter. The shareAccess parameter controls what permissions other clients have when trying to access the same file while this instance is still open. This value is either FILE_NO_SHARE or any combination of FILE_SHARE_READ, FILE_SHARE_WRITE, and FILE_SHARE_DELETE logically OR'd together.
Parameters:
  context - A URL string
Parameters:
  name - A path string relative to the context paremeter
Parameters:
  auth - The credentials the client should use for authentication
Parameters:
  shareAccess - Specifies what access other clients have while this file is open.
throws:
  MalformedURLException - If the context and name parametersdo not follow the prescribed syntax



SmbFile
public SmbFile(SmbFile context, String name, int shareAccess) throws MalformedURLException, UnknownHostException(Code)
Constructs an SmbFile representing a resource on an SMB network such as a file or directory. The second parameter is a relative path from the context. See the description above for examples of using the second name parameter. The shareAccess parameter controls what permissions other clients have when trying to access the same file while this instance is still open. This value is either FILE_NO_SHARE or any combination of FILE_SHARE_READ, FILE_SHARE_WRITE, and FILE_SHARE_DELETE logically OR'd together.
Parameters:
  context - A base SmbFile
Parameters:
  name - A path string relative to the context file path
Parameters:
  shareAccess - Specifies what access other clients have while this file is open.
throws:
  MalformedURLException - If the context and name parametersdo not follow the prescribed syntax



SmbFile
public SmbFile(URL url)(Code)
Constructs an SmbFile representing a resource on an SMB network such as a file or directory from a URL object.
Parameters:
  url - The URL of the target resource



SmbFile
public SmbFile(URL url, NtlmPasswordAuthentication auth)(Code)
Constructs an SmbFile representing a resource on an SMB network such as a file or directory from a URL object and an NtlmPasswordAuthentication object.
Parameters:
  url - The URL of the target resource
Parameters:
  auth - The credentials the client should use for authentication



SmbFile
SmbFile(SmbFile context, String name, int type, int attributes, long createTime, long lastModified, long size) throws MalformedURLException, UnknownHostException(Code)




Method Detail
canRead
public boolean canRead() throws SmbException(Code)
Tests to see if the file this SmbFile represents can be read. Because any file, directory, or other resource can be read if it exists, this method simply calls the exists method. true if the file is read-only



canWrite
public boolean canWrite() throws SmbException(Code)
Tests to see if the file this SmbFile represents exists and is not marked read-only. By default, resources are considered to be read-only and therefore for smb://, smb://workgroup/, and smb://server/ resources will be read-only. true if the resource exists is not markedread-only



close
void close(int f, long lastWriteTime) throws SmbException(Code)



close
void close(long lastWriteTime) throws SmbException(Code)



close
void close() throws SmbException(Code)



connect
public void connect() throws IOException(Code)
It is not necessary to call this method directly. This is the URLConnection implementation of connect().



connect0
void connect0() throws SmbException(Code)



copyTo
public void copyTo(SmbFile dest) throws SmbException(Code)
This method will copy the file or directory represented by this SmbFile and it's sub-contents to the location specified by the dest parameter. This file and the destination file do not need to be on the same host. This operation does not copy extended file attibutes such as ACLs but it does copy regular attributes as well as create and last write times. This method is almost twice as efficient as manually copying as it employs an additional write thread to read and write data concurrently.

It is not possible (nor meaningful) to copy entire workgroups or servers.
Parameters:
  dest - the destination file or directory
throws:
  SmbException -




copyTo0
void copyTo0(SmbFile dest, byte[][] b, int bsize, WriterThread w, SmbComReadAndX req, SmbComReadAndXResponse resp) throws SmbException(Code)



createNewFile
public void createNewFile() throws SmbException(Code)
Create a new file but fail if it already exists. The check for existance of the file and it's creation are an atomic operation with respect to other filesystem activities.



createTime
public long createTime() throws SmbException(Code)
Retrieve the time this SmbFile was created. The value returned is suitable for constructing a java.util.Date object (i.e. seconds since Epoch 1970). Times should be the same as those reported using the properties dialog of the Windows Explorer program. For Win95/98/Me this is actually the last write time. It is currently not possible to retrieve the create time from files on these systems. The number of milliseconds since the 00:00:00 GMT, January 1,1970 as a long value



delete
public void delete() throws SmbException(Code)
This method will delete the file or directory specified by this SmbFile. If the target is a directory, the contents of the directory will be deleted as well. If a file within the directory or it's sub-directories is marked read-only, the read-only status will be removed and the file will be deleted.
throws:
  SmbException -



delete
void delete(String fileName) throws SmbException(Code)



doFindFirstNext
void doFindFirstNext(ArrayList list, boolean files, String wildcard, int searchAttributes, SmbFilenameFilter fnf, SmbFileFilter ff) throws SmbException, UnknownHostException, MalformedURLException(Code)



doNetEnum
void doNetEnum(ArrayList list, boolean files, String wildcard, int searchAttributes, SmbFilenameFilter fnf, SmbFileFilter ff) throws SmbException, UnknownHostException, MalformedURLException(Code)



equals
public boolean equals(Object obj)(Code)
Tests to see if two SmbFile objects are equal. Two SmbFile objects are equal when they reference the same SMB resource. More specifically, two SmbFile objects are equals if their server IP addresses are equal and the canonicalized representation of their URLs, minus authentication parameters, are case insensitivly and lexographically equal.

For example, assuming the server angus resolves to the 192.168.1.15 IP address, the below URLs would result in SmbFiles that are equal.

 smb://192.168.1.15/share/DIR/foo.txt
 smb://angus/share/data/../dir/foo.txt
 

Parameters:
  obj - Another SmbFile object to compare for equality true if the two objects refer to the same SMB resourceand false otherwise
throws:
  SmbException -



exists
public boolean exists() throws SmbException(Code)
Tests to see if the SMB resource exists. If the resource refers only to a server, this method determines if the server exists on the network and is advertising SMB services. If this resource refers to a workgroup, this method determines if the workgroup name is valid on the local SMB network. If this SmbFile refers to the root smb:// resource true is always returned. If this SmbFile is a traditional file or directory, it will be queried for on the specified server as expected. true if the resource exists or is alive orfalse otherwise



getAddress
UniAddress getAddress() throws UnknownHostException(Code)



getAttributes
public int getAttributes() throws SmbException(Code)
Return the attributes of this file. Attributes are represented as a bitset that must be masked with ATTR_* constants to determine if they are set or unset. The value returned is suitable for use with the setAttributes() method. the ATTR_* attributes associated with this file
throws:
  SmbException -



getCanonicalPath
public String getCanonicalPath()(Code)
Returns the full URL of this SMB resource with '.' and '..' components factored out. An SmbFile constructed with the result of this method will result in an SmbFile that is equal to the original. The canonicalized URL of this SMB resource.



getContentLength
public int getContentLength()(Code)
This URLConnection method just returns the result of length(). the length of this file or 0 if it refers to a directory



getDate
public long getDate()(Code)
This URLConnection method just returns the result of lastModified. the last modified data as milliseconds since Jan 1, 1970



getDfsPath
public String getDfsPath() throws SmbException(Code)
If the path of this SmbFile falls within a DFS volume, this method will return the referral path to which it maps. Otherwise null is returned.



getDiskFreeSpace
public long getDiskFreeSpace() throws SmbException(Code)
This method returns the free disk space in bytes of the drive this share represents or the drive on which the directory or file resides. Objects other than TYPE_SHARE or TYPE_FILESYSTEM will result in 0L being returned. the free disk space in bytes of the drive on which this file ordirectory resides



getInputStream
public InputStream getInputStream() throws IOException(Code)
This URLConnection method just returns a new SmbFileInputStream created with this file.
throws:
  IOException - thrown by SmbFileInputStream constructor



getLastModified
public long getLastModified()(Code)
This URLConnection method just returns the result of lastModified. the last modified data as milliseconds since Jan 1, 1970



getName
public String getName()(Code)
Returns the last component of the target URL. This will effectively be the name of the file or directory represented by this SmbFile or in the case of URLs that only specify a server or workgroup, the server or workgroup will be returned. The name of the root URL smb:// is also smb://. If this SmbFile refers to a workgroup, server, share, or directory, the name will include a trailing slash '/' so that composing new SmbFiles will maintain the trailing slash requirement. The last component of the URL associated with this SMBresource or smb:// if the resource is smb://itself.



getOutputStream
public OutputStream getOutputStream() throws IOException(Code)
This URLConnection method just returns a new SmbFileOutputStream created with this file.
throws:
  IOException - thrown by SmbFileOutputStream constructor



getParent
public String getParent()(Code)
Everything but the last component of the URL representing this SMB resource is effectivly it's parent. The root URL smb:// does not have a parent. In this case smb:// is returned. The parent directory of this SMB resource orsmb:// if the resource refers to the root of the URLhierarchy which incedentally is also smb://.



getPath
public String getPath()(Code)
Returns the full uncanonicalized URL of this SMB resource. An SmbFile constructed with the result of this method will result in an SmbFile that is equal to the original. The uncanonicalized full URL of this SMB resource.



getPrincipal
public Principal getPrincipal()(Code)
Returns the NtlmPasswordAuthentication object used as credentials with this file or pipe. This can be used to retrieve the username for example: String username = f.getPrincipal().getName(); The Principal object returned will never be null however the username can be null indication anonymous credentials were used (e.g. some IPC$ services).



getServer
public String getServer()(Code)
Retrieve the hostname of the server for this SMB resource. If this SmbFile references a workgroup, the name of the workgroup is returned. If this SmbFile refers to the root of this SMB network hierarchy, null is returned. The server or workgroup name or null if thisSmbFile refers to the root smb:// resource.



getShare
public String getShare()(Code)
Retrieves the share associated with this SMB resource. In the case of smb://, smb://workgroup/, and smb://server/ URLs which do not specify a share, null will be returned. The share component or null if there is no share



getType
public int getType() throws SmbException(Code)
Returns type of of object this SmbFile represents. TYPE_FILESYSTEM, TYPE_WORKGROUP, TYPE_SERVER, TYPE_SHARE,TYPE_PRINTER, TYPE_NAMED_PIPE, or TYPE_COMM.



getUncPath
public String getUncPath()(Code)
Retuns the Windows UNC style path with backslashs intead of forward slashes. The UNC path.



getUncPath0
String getUncPath0()(Code)



hashCode
public int hashCode()(Code)
Computes a hashCode for this file based on the URL string and IP address if the server. The hashing function uses the hashcode of the server address, the canonical representation of the URL, and does not compare authentication information. In essance, two SmbFile objects that refer to the same file should generate the same hashcode provided it is possible to make such a determination. A hashcode for this abstract file
throws:
  SmbException -



isConnected
boolean isConnected()(Code)



isDirectory
public boolean isDirectory() throws SmbException(Code)
Tests to see if the file this SmbFile represents is a directory. true if this SmbFile is a directory



isFile
public boolean isFile() throws SmbException(Code)
Tests to see if the file this SmbFile represents is not a directory. true if this SmbFile is not a directory



isHidden
public boolean isHidden() throws SmbException(Code)
Tests to see if the file this SmbFile represents is marked as hidden. This method will also return true for shares with names that end with '$' such as IPC$ or C$. true if the SmbFile is marked as being hidden



isOpen
boolean isOpen()(Code)



isWorkgroup0
boolean isWorkgroup0() throws UnknownHostException(Code)



lastModified
public long lastModified() throws SmbException(Code)
Retrieve the last time the file represented by this SmbFile was modified. The value returned is suitable for constructing a java.util.Date object (i.e. seconds since Epoch 1970). Times should be the same as those reported using the properties dialog of the Windows Explorer program. The number of milliseconds since the 00:00:00 GMT, January 1,1970 as a long value



length
public long length() throws SmbException(Code)
Returns the length of this SmbFile in bytes. If this object is a TYPE_SHARE the total capacity of the disk shared in bytes is returned. If this object is a directory or a type other than TYPE_SHARE, 0L is returned. The length of the file in bytes or 0 if thisSmbFile is not a file.
throws:
  SmbException -



list
public String[] list() throws SmbException(Code)
List the contents of this SMB resource. The list returned by this method will be;
  • files and directories contained within this resource if the resource is a normal disk file directory,
  • all available NetBIOS workgroups or domains if this resource is the top level URL smb://,
  • all servers registered as members of a NetBIOS workgroup if this resource refers to a workgroup in a smb://workgroup/ URL,
  • all browseable shares of a server including printers, IPC services, or disk volumes if this resource is a server URL in the form smb://server/,
  • or null if the resource cannot be resolved.
A String[] array of files and directories,workgroups, servers, or shares depending on the context of theresource URL



list
public String[] list(SmbFilenameFilter filter) throws SmbException(Code)
List the contents of this SMB resource. The list returned will be identical to the list returned by the parameterless list() method minus filenames filtered by the specified filter.
Parameters:
  filter - a filename filter to exclude filenames from the results
throws:
  SmbException - # @return An array of filenames



list
String[] list(String wildcard, int searchAttributes, SmbFilenameFilter fnf, SmbFileFilter ff) throws SmbException(Code)



listFiles
public SmbFile[] listFiles() throws SmbException(Code)
List the contents of this SMB resource as an array of SmbFile objects. This method is much more efficient than the regular list method when querying attributes of each file in the result set.

The list of SmbFiles returned by this method will be;

  • files and directories contained within this resource if the resource is a normal disk file directory,
  • all available NetBIOS workgroups or domains if this resource is the top level URL smb://,
  • all servers registered as members of a NetBIOS workgroup if this resource refers to a workgroup in a smb://workgroup/ URL,
  • all browseable shares of a server including printers, IPC services, or disk volumes if this resource is a server URL in the form smb://server/,
  • or null if the resource cannot be resolved.
An array of SmbFile objects representing fileand directories, workgroups, servers, or shares depending on the contextof the resource URL



listFiles
public SmbFile[] listFiles(String wildcard) throws SmbException(Code)
The CIFS protocol provides for DOS "wildcards" to be used as a performance enhancement. The client does not have to filter the names and the server does not have to return all directory entries.

The wildcard expression may consist of two special meta characters in addition to the normal filename characters. The '*' character matches any number of characters in part of a name. If the expression begins with one or more '?'s then exactly that many characters will be matched whereas if it ends with '?'s it will match that many characters or less.

Wildcard expressions will not filter workgroup names or server names.

 winnt> ls c?o*
 clock.avi                  -rw--      82944 Mon Oct 14 1996 1:38 AM
 Cookies                    drw--          0 Fri Nov 13 1998 9:42 PM
 2 items in 5ms
 

Parameters:
  wildcard - a wildcard expression
throws:
  SmbException - An array of SmbFile objects representing fileand directories, workgroups, servers, or shares depending on the contextof the resource URL



listFiles
public SmbFile[] listFiles(SmbFilenameFilter filter) throws SmbException(Code)
List the contents of this SMB resource. The list returned will be identical to the list returned by the parameterless listFiles() method minus files filtered by the specified filename filter.
Parameters:
  filter - a filter to exclude files from the results An array of SmbFile objects
throws:
  SmbException -



listFiles
public SmbFile[] listFiles(SmbFileFilter filter) throws SmbException(Code)
List the contents of this SMB resource. The list returned will be identical to the list returned by the parameterless listFiles() method minus filenames filtered by the specified filter.
Parameters:
  filter - a file filter to exclude files from the results An array of SmbFile objects



listFiles
SmbFile[] listFiles(String wildcard, int searchAttributes, SmbFilenameFilter fnf, SmbFileFilter ff) throws SmbException(Code)



mkdir
public void mkdir() throws SmbException(Code)
Creates a directory with the path specified by this SmbFile. For this method to be successful, the target must not already exist. This method will fail when used with smb://, smb://workgroup/, smb://server/, or smb://server/share/ URLs because workgroups, servers, and shares cannot be dynamically created (although in the future it may be possible to create shares).
throws:
  SmbException -



mkdirs
public void mkdirs() throws SmbException(Code)
Creates a directory with the path specified by this SmbFile and any parent directories that do not exist. This method will fail when used with smb://, smb://workgroup/, smb://server/, or smb://server/share/ URLs because workgroups, servers, and shares cannot be dynamically created (although in the future it may be possible to create shares).
throws:
  SmbException -



open
void open(int flags, int attrs, int options) throws SmbException(Code)



open0
int open0(int flags, int attrs, int options) throws SmbException(Code)



queryLookup
static String queryLookup(String query, String param)(Code)



queryPath
Info queryPath(String path, int infoLevel) throws SmbException(Code)



renameTo
public void renameTo(SmbFile dest) throws SmbException(Code)
Changes the name of the file this SmbFile represents to the name designated by the SmbFile argument.

Remember: SmbFiles are immutible and therefore the path associated with this SmbFile object will not change). To access the renamed file it is necessary to construct a new SmbFile.
Parameters:
  dest - An SmbFile that represents the new pathname true if the file or directory was successfully renamed
throws:
  NullPointerException - If the dest argument is null




send
void send(ServerMessageBlock request, ServerMessageBlock response) throws SmbException(Code)



sendTransaction
void sendTransaction(SmbComTransaction request, SmbComTransactionResponse response) throws SmbException(Code)



setAttributes
public void setAttributes(int attrs) throws SmbException(Code)
Set the attributes of this file. Attributes are composed into a bitset by bitwise ORing the ATTR_* constants. Setting the value returned by getAttributes will result in both files having the same attributes.
throws:
  SmbException -



setCreateTime
public void setCreateTime(long time) throws SmbException(Code)
Set the create time of the file. The time is specified as milliseconds from Jan 1, 1970 which is the same as that which is returned by the createTime() method.

This method does not apply to workgroups, servers, or shares.
Parameters:
  time - the create time as milliseconds since Jan 1, 1970




setLastModified
public void setLastModified(long time) throws SmbException(Code)
Set the last modified time of the file. The time is specified as milliseconds from Jan 1, 1970 which is the same as that which is returned by the lastModified(), getLastModified(), and getDate() methods.

This method does not apply to workgroups, servers, or shares.
Parameters:
  time - the last modified time as milliseconds since Jan 1, 1970




setPathInformation
void setPathInformation(int attrs, long ctime, long mtime) throws SmbException(Code)



setReadOnly
public void setReadOnly() throws SmbException(Code)
Make this file read-only. This is shorthand for setAttributes( getAttributes() | ATTR_READ_ONLY ).
throws:
  SmbException -



setReadWrite
public void setReadWrite() throws SmbException(Code)
Turn off the read-only attribute of this file. This is shorthand for setAttributes( getAttributes() & ~ATTR_READONLY ).
throws:
  SmbException -



toString
public String toString()(Code)
Returns the string representation of this SmbFile object. This will be the same as the URL used to construct this SmbFile. This method will return the same value as getPath. The original URL representation of this SMB resource
throws:
  SmbException -



toURL
public URL toURL() throws MalformedURLException(Code)
Returns a java.net.URL for this SmbFile. The URL may be used as any other URL might to access an SMB resource. Currently only retrieving data and information is supported (i.e. no doOutput). A new java.net.URL for this SmbFile
throws:
  MalformedURLException -



Fields inherited from java.net.URLConnection
protected boolean allowUserInteraction(Code)(Java Doc)
protected boolean connected(Code)(Java Doc)
protected boolean doInput(Code)(Java Doc)
protected boolean doOutput(Code)(Java Doc)
protected long ifModifiedSince(Code)(Java Doc)
protected URL url(Code)(Java Doc)
protected boolean useCaches(Code)(Java Doc)

Methods inherited from java.net.URLConnection
public void addRequestProperty(String key, String value)(Code)(Java Doc)
abstract public void connect() throws IOException(Code)(Java Doc)
public boolean getAllowUserInteraction()(Code)(Java Doc)
public int getConnectTimeout()(Code)(Java Doc)
public Object getContent() throws IOException(Code)(Java Doc)
public Object getContent(Class[] classes) throws IOException(Code)(Java Doc)
public String getContentEncoding()(Code)(Java Doc)
public int getContentLength()(Code)(Java Doc)
public String getContentType()(Code)(Java Doc)
public long getDate()(Code)(Java Doc)
public static boolean getDefaultAllowUserInteraction()(Code)(Java Doc)
public static String getDefaultRequestProperty(String key)(Code)(Java Doc)
public boolean getDefaultUseCaches()(Code)(Java Doc)
public boolean getDoInput()(Code)(Java Doc)
public boolean getDoOutput()(Code)(Java Doc)
public long getExpiration()(Code)(Java Doc)
public static synchronized FileNameMap getFileNameMap()(Code)(Java Doc)
public String getHeaderField(String name)(Code)(Java Doc)
public String getHeaderField(int n)(Code)(Java Doc)
public long getHeaderFieldDate(String name, long Default)(Code)(Java Doc)
public int getHeaderFieldInt(String name, int Default)(Code)(Java Doc)
public String getHeaderFieldKey(int n)(Code)(Java Doc)
public Map<String, List<String>> getHeaderFields()(Code)(Java Doc)
public long getIfModifiedSince()(Code)(Java Doc)
public InputStream getInputStream() throws IOException(Code)(Java Doc)
public long getLastModified()(Code)(Java Doc)
public OutputStream getOutputStream() throws IOException(Code)(Java Doc)
public Permission getPermission() throws IOException(Code)(Java Doc)
public int getReadTimeout()(Code)(Java Doc)
public Map<String, List<String>> getRequestProperties()(Code)(Java Doc)
public String getRequestProperty(String key)(Code)(Java Doc)
public URL getURL()(Code)(Java Doc)
public boolean getUseCaches()(Code)(Java Doc)
public static String guessContentTypeFromName(String fname)(Code)(Java Doc)
public static String guessContentTypeFromStream(InputStream is) throws IOException(Code)(Java Doc)
public void setAllowUserInteraction(boolean allowuserinteraction)(Code)(Java Doc)
public void setConnectTimeout(int timeout)(Code)(Java Doc)
public static synchronized void setContentHandlerFactory(ContentHandlerFactory fac)(Code)(Java Doc)
public static void setDefaultAllowUserInteraction(boolean defaultallowuserinteraction)(Code)(Java Doc)
public static void setDefaultRequestProperty(String key, String value)(Code)(Java Doc)
public void setDefaultUseCaches(boolean defaultusecaches)(Code)(Java Doc)
public void setDoInput(boolean doinput)(Code)(Java Doc)
public void setDoOutput(boolean dooutput)(Code)(Java Doc)
public static void setFileNameMap(FileNameMap map)(Code)(Java Doc)
public void setIfModifiedSince(long ifmodifiedsince)(Code)(Java Doc)
public void setReadTimeout(int timeout)(Code)(Java Doc)
public void setRequestProperty(String key, String value)(Code)(Java Doc)
public void setUseCaches(boolean usecaches)(Code)(Java Doc)
public String toString()(Code)(Java Doc)

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.