This class represents a resource on an SMB network. Mainly these
resources are files and directories however an
may also refer to servers and workgroups. If the resource is a file or
directory the methods of
follow the behavior of
the well known
java.io.File class. One fundamental difference
is the usage of a URL scheme  to specify the target file or
directory. SmbFile URLs have the following syntax:
would reference the file
in the share
on the server
. In addition
to referencing files and directories, jCIFS can also address servers,
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.
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:
 This URL scheme is based largely on the SMB
Filesharing URL Scheme IETF draft.
|SMB URL Examples
This URL references a share called |
tmp on the server
angus as user
miallen who's password is
A relativly sophisticated example that references a file
msmith1's desktop as user
Administrator. Notice the '@' is URL encoded with the '%40' hexcode escape.
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.
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
Just as |
smb://server/ lists shares and
smb://workgroup/ lists servers, the
URL lists all available workgroups on a netbios LAN. Again,
in this context many methods are not valid and return default
isHidden will always return false).
The server name may also be a DNS name as it is in this example. See
Setting Name Resolution Properties
The server name may also be an IP address. See Setting Name Resolution Properties
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 URLs support some query string parameters. In this example
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
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 Parameter||Second Parameter||Result|
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.