public class SmbFile
extends java.net.URLConnection
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 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:
This example:smb://[[[domain;]username[:password]@]server[:port]/[[share/[dir/]file]]][?param=value[param2=value2[...]]]
would reference the filesmb://storage15/public/foo.txt
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 | |
URL | Description |
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 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 Parameter | Second Parameter | Result |
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 |
Instances of the SmbFile
class are immutable; that is,
once created, the abstract pathname represented by an SmbFile object
will never change.
File
Modifier and Type | Field and Description |
---|---|
static int |
ATTR_ARCHIVE
A file with this bit on as returned by getAttributes() or set
with setAttributes() is an archived file
|
static int |
ATTR_DIRECTORY
A file with this bit on as returned by getAttributes() is
a directory
|
static int |
ATTR_HIDDEN
A file with this bit on as returned by getAttributes() or set
with setAttributes() will be hidden
|
static int |
ATTR_READONLY
A file with this bit on as returned by getAttributes() or set
with setAttributes() will be read-only
|
static int |
ATTR_SYSTEM
A file with this bit on as returned by getAttributes() or set
with setAttributes() will be a system file
|
static int |
ATTR_VOLUME
A file with this bit on as returned by getAttributes() is
a volume
|
static int |
CAP_DFS |
static int |
CAP_EXTENDED_SECURITY |
static int |
CAP_LARGE_FILES |
static int |
CAP_LEVEL_II_OPLOCKS |
static int |
CAP_LOCK_AND_READ |
static int |
CAP_MPX_MODE |
static int |
CAP_NONE |
static int |
CAP_NT_FIND |
static int |
CAP_NT_SMBS |
static int |
CAP_RAW_MODE |
static int |
CAP_RPC_REMOTE_APIS |
static int |
CAP_STATUS32 |
static int |
CAP_UNICODE |
static int |
CAPABILITIES |
static int |
CMD_OFFSET |
static int |
CONN_TIMEOUT |
static java.util.LinkedList |
CONNECTIONS |
static int |
DEFAULT_CAPABILITIES |
static int |
DEFAULT_CONN_TIMEOUT |
static int |
DEFAULT_FLAGS2 |
static int |
DEFAULT_MAX_MPX_COUNT |
static int |
DEFAULT_PORT |
static int |
DEFAULT_RCV_BUF_SIZE |
static int |
DEFAULT_RESPONSE_TIMEOUT |
static int |
DEFAULT_SND_BUF_SIZE |
static int |
DEFAULT_SO_TIMEOUT |
static int |
DEFAULT_SSN_LIMIT |
static int |
DELETE |
protected static jcifs.smb.Dfs |
dfs |
static int |
ERROR_CODE_OFFSET |
static int |
FILE_APPEND_DATA |
static int |
FILE_DELETE |
static int |
FILE_EXECUTE |
static int |
FILE_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.
|
static int |
FILE_READ_ATTRIBUTES |
static int |
FILE_READ_DATA |
static int |
FILE_READ_EA |
static int |
FILE_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.
|
static int |
FILE_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.
|
static int |
FILE_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.
|
static int |
FILE_WRITE_ATTRIBUTES |
static int |
FILE_WRITE_DATA |
static int |
FILE_WRITE_EA |
static int |
FLAGS_COPY_SOURCE_MODE_ASCII |
static int |
FLAGS_COPY_TARGET_MODE_ASCII |
static int |
FLAGS_LOCK_AND_READ_WRITE_AND_UNLOCK |
static int |
FLAGS_NONE |
static int |
FLAGS_NOTIFY_OF_MODIFY_ACTION |
static int |
FLAGS_OFFSET |
static int |
FLAGS_OPLOCK_REQUESTED_OR_GRANTED |
static int |
FLAGS_PATH_NAMES_CANONICALIZED |
static int |
FLAGS_PATH_NAMES_CASELESS |
static int |
FLAGS_RECEIVE_BUFFER_POSTED |
static int |
FLAGS_RESPONSE |
static int |
FLAGS_TARGET_MUST_BE_DIRECTORY |
static int |
FLAGS_TARGET_MUST_BE_FILE |
static int |
FLAGS_TREE_COPY |
static int |
FLAGS_VERIFY_ALL_WRITES |
static int |
FLAGS2 |
static int |
FLAGS2_EXTENDED_ATTRIBUTES |
static int |
FLAGS2_EXTENDED_SECURITY_NEGOTIATION |
static int |
FLAGS2_LONG_FILENAMES |
static int |
FLAGS2_NONE |
static int |
FLAGS2_PERMIT_READ_IF_EXECUTE_PERM |
static int |
FLAGS2_RESOLVE_PATHS_IN_DFS |
static int |
FLAGS2_SECURITY_SIGNATURES |
static int |
FLAGS2_STATUS32 |
static int |
FLAGS2_UNICODE |
static boolean |
FORCE_UNICODE |
static int |
GENERIC_ALL |
static int |
GENERIC_EXECUTE |
static int |
GENERIC_READ |
static int |
GENERIC_WRITE |
static int |
HEADER_LENGTH |
static java.net.InetAddress |
LADDR |
static int |
LM_COMPATIBILITY |
static int |
LPORT |
static int |
MAX_MPX_COUNT |
static long |
MILLISECONDS_BETWEEN_1970_AND_1601 |
static java.lang.String |
NATIVE_LANMAN |
static java.lang.String |
NATIVE_OS |
static java.lang.String |
NETBIOS_HOSTNAME |
static jcifs.smb.SmbTransport |
NULL_TRANSPORT |
static java.lang.String |
OEM_ENCODING |
static int |
OPEN_FUNCTION_FAIL_IF_EXISTS |
static int |
OPEN_FUNCTION_OVERWRITE_IF_EXISTS |
static int |
PID |
static int |
RCV_BUF_SIZE |
static int |
READ_CONTROL |
static int |
RESPONSE_TIMEOUT |
static int |
SECURITY_SHARE |
static int |
SECURITY_USER |
static int |
SIGNATURE_OFFSET |
static boolean |
SIGNPREF |
static int |
SND_BUF_SIZE |
static int |
SO_TIMEOUT |
static int |
SSN_LIMIT |
static int |
SYNCHRONIZE |
static boolean |
TCP_NODELAY |
static int |
TID_OFFSET |
static int |
TYPE_COMM
Returned by
getType() if the resource this SmbFile
represents is a communications device. |
static int |
TYPE_FILESYSTEM
Returned by
getType() if the resource this SmbFile
represents is a regular file or directory. |
static int |
TYPE_NAMED_PIPE
Returned by
getType() if the resource this SmbFile
represents is a named pipe. |
static int |
TYPE_PRINTER
Returned by
getType() if the resource this SmbFile
represents is a printer. |
static int |
TYPE_SERVER
Returned by
getType() if the resource this SmbFile
represents is a server. |
static int |
TYPE_SHARE
Returned by
getType() if the resource this SmbFile
represents is a share. |
static int |
TYPE_WORKGROUP
Returned by
getType() if the resource this SmbFile
represents is a workgroup. |
static java.util.TimeZone |
TZ |
static java.lang.String |
UNI_ENCODING |
static boolean |
USE_BATCHING |
static boolean |
USE_EXTSEC |
static boolean |
USE_NTSMBS |
static boolean |
USE_NTSTATUS |
static boolean |
USE_UNICODE |
static int |
VC_NUMBER |
static int |
WRITE_DAC |
static int |
WRITE_OWNER |
Constructor and Description |
---|
SmbFile(SmbFile context,
java.lang.String name)
Constructs an SmbFile representing a resource on an SMB network such
as a file or directory.
|
SmbFile(SmbFile context,
java.lang.String name,
int shareAccess)
Constructs an SmbFile representing a resource on an SMB network such
as a file or directory.
|
SmbFile(java.lang.String url)
Constructs an SmbFile representing a resource on an SMB network such as
a file or directory.
|
SmbFile(java.lang.String url,
NtlmPasswordAuthentication auth)
Constructs an SmbFile representing a resource on an SMB network such
as a file or directory.
|
SmbFile(java.lang.String url,
NtlmPasswordAuthentication auth,
int shareAccess)
Constructs an SmbFile representing a file on an SMB network.
|
SmbFile(java.lang.String context,
java.lang.String name)
Constructs an SmbFile representing a resource on an SMB network such
as a file or directory.
|
SmbFile(java.lang.String context,
java.lang.String name,
NtlmPasswordAuthentication auth)
Constructs an SmbFile representing a resource on an SMB network such
as a file or directory.
|
SmbFile(java.lang.String context,
java.lang.String name,
NtlmPasswordAuthentication auth,
int shareAccess)
Constructs an SmbFile representing a resource on an SMB network such
as a file or directory.
|
SmbFile(java.net.URL url)
Constructs an SmbFile representing a resource on an SMB network such
as a file or directory from a URL object.
|
SmbFile(java.net.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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canRead()
Tests to see if the file this
SmbFile represents can be
read. |
boolean |
canWrite()
Tests to see if the file this
SmbFile represents
exists and is not marked read-only. |
void |
connect()
It is not necessary to call this method directly.
|
void |
copyTo(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.
|
void |
createNewFile()
Create a new file but fail if it already exists.
|
long |
createTime()
Retrieve the time this
SmbFile was created. |
void |
delete()
This method will delete the file or directory specified by this
SmbFile . |
boolean |
equals(java.lang.Object obj)
Tests to see if two
SmbFile objects are equal. |
boolean |
exists()
Tests to see if the SMB resource exists.
|
int |
getAttributes()
Return the attributes of this file.
|
java.lang.String |
getCanonicalPath()
Returns the full URL of this SMB resource with '.' and '..' components
factored out.
|
int |
getContentLength()
This URLConnection method just returns the result of length().
|
long |
getDate()
This URLConnection method just returns the result of lastModified.
|
java.lang.String |
getDfsPath()
If the path of this
SmbFile falls within a DFS volume,
this method will return the referral path to which it maps. |
long |
getDiskFreeSpace()
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.
|
java.io.InputStream |
getInputStream()
This URLConnection method just returns a new SmbFileInputStream created with this file.
|
long |
getLastModified()
This URLConnection method just returns the result of lastModified.
|
java.lang.String |
getName()
Returns the last component of the target URL.
|
java.io.OutputStream |
getOutputStream()
This URLConnection method just returns a new SmbFileOutputStream created with this file.
|
java.lang.String |
getParent()
Everything but the last component of the URL representing this SMB
resource is effectivly it's parent.
|
java.lang.String |
getPath()
Returns the full uncanonicalized URL of this SMB resource.
|
java.security.Principal |
getPrincipal()
Returns the NtlmPasswordAuthentication object used as
credentials with this file or pipe.
|
ACE[] |
getSecurity()
Return an array of Access Control Entry (ACE) objects representing
the security descriptor associated with this file or directory.
|
ACE[] |
getSecurity(boolean resolveSids)
Return an array of Access Control Entry (ACE) objects representing
the security descriptor associated with this file or directory.
|
java.lang.String |
getServer()
Retrieve the hostname of the server for this SMB resource.
|
java.lang.String |
getShare()
Retrieves the share associated with this SMB resource.
|
ACE[] |
getShareSecurity(boolean resolveSids)
Return an array of Access Control Entry (ACE) objects representing
the share permissions on the share exporting this file or directory.
|
int |
getType()
Returns type of of object this SmbFile represents.
|
java.lang.String |
getUncPath()
Retuns the Windows UNC style path with backslashs intead of forward slashes.
|
int |
hashCode()
Computes a hashCode for this file based on the URL string and IP
address if the server.
|
boolean |
isDirectory()
Tests to see if the file this
SmbFile represents is a directory. |
boolean |
isFile()
Tests to see if the file this
SmbFile represents is not a directory. |
boolean |
isHidden()
Tests to see if the file this SmbFile represents is marked as
hidden.
|
long |
lastModified()
Retrieve the last time the file represented by this
SmbFile was modified. |
long |
length()
Returns the length of this SmbFile in bytes.
|
java.lang.String[] |
list()
List the contents of this SMB resource.
|
java.lang.String[] |
list(SmbFilenameFilter filter)
List the contents of this SMB resource.
|
SmbFile[] |
listFiles()
List the contents of this SMB resource as an array of
SmbFile objects. |
SmbFile[] |
listFiles(SmbFileFilter filter)
List the contents of this SMB resource.
|
SmbFile[] |
listFiles(SmbFilenameFilter filter)
List the contents of this SMB resource.
|
SmbFile[] |
listFiles(java.lang.String wildcard)
The CIFS protocol provides for DOS "wildcards" to be used as
a performance enhancement.
|
void |
mkdir()
Creates a directory with the path specified by this
SmbFile . |
void |
mkdirs()
Creates a directory with the path specified by this SmbFile
and any parent directories that do not exist.
|
protected boolean |
pathNamesPossiblyEqual(java.lang.String path1,
java.lang.String path2) |
void |
renameTo(SmbFile dest)
Changes the name of the file this
SmbFile represents to the name
designated by the SmbFile argument. |
void |
setAttributes(int attrs)
Set the attributes of this file.
|
void |
setCreateTime(long time)
Set the create time of the file.
|
void |
setLastModified(long time)
Set the last modified time of the file.
|
void |
setReadOnly()
Make this file read-only.
|
void |
setReadWrite()
Turn off the read-only attribute of this file.
|
java.lang.String |
toString()
Returns the string representation of this SmbFile object.
|
java.net.URL |
toURL()
Deprecated.
Use getURL() instead
|
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLengthLong, getContentType, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFieldLong, getHeaderFields, getIfModifiedSince, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches
public static final int FILE_NO_SHARE
public static final int FILE_SHARE_READ
public static final int FILE_SHARE_WRITE
public static final int FILE_SHARE_DELETE
public static final int ATTR_READONLY
public static final int ATTR_HIDDEN
public static final int ATTR_SYSTEM
public static final int ATTR_VOLUME
public static final int ATTR_DIRECTORY
public static final int ATTR_ARCHIVE
public static final int TYPE_FILESYSTEM
getType()
if the resource this SmbFile
represents is a regular file or directory.public static final int TYPE_WORKGROUP
getType()
if the resource this SmbFile
represents is a workgroup.public static final int TYPE_SERVER
getType()
if the resource this SmbFile
represents is a server.public static final int TYPE_SHARE
getType()
if the resource this SmbFile
represents is a share.public static final int TYPE_NAMED_PIPE
getType()
if the resource this SmbFile
represents is a named pipe.public static final int TYPE_PRINTER
getType()
if the resource this SmbFile
represents is a printer.public static final int TYPE_COMM
getType()
if the resource this SmbFile
represents is a communications device.protected static jcifs.smb.Dfs dfs
public static final int DEFAULT_PORT
public static final int DEFAULT_MAX_MPX_COUNT
public static final int DEFAULT_RESPONSE_TIMEOUT
public static final int DEFAULT_SO_TIMEOUT
public static final int DEFAULT_RCV_BUF_SIZE
public static final int DEFAULT_SND_BUF_SIZE
public static final int DEFAULT_SSN_LIMIT
public static final int DEFAULT_CONN_TIMEOUT
public static final java.net.InetAddress LADDR
public static final int LPORT
public static final int MAX_MPX_COUNT
public static final int SND_BUF_SIZE
public static final int RCV_BUF_SIZE
public static final boolean USE_UNICODE
public static final boolean FORCE_UNICODE
public static final boolean USE_NTSTATUS
public static final boolean SIGNPREF
public static final boolean USE_NTSMBS
public static final boolean USE_EXTSEC
public static final java.lang.String NETBIOS_HOSTNAME
public static final int LM_COMPATIBILITY
public static final int FLAGS_NONE
public static final int FLAGS_LOCK_AND_READ_WRITE_AND_UNLOCK
public static final int FLAGS_RECEIVE_BUFFER_POSTED
public static final int FLAGS_PATH_NAMES_CASELESS
public static final int FLAGS_PATH_NAMES_CANONICALIZED
public static final int FLAGS_OPLOCK_REQUESTED_OR_GRANTED
public static final int FLAGS_NOTIFY_OF_MODIFY_ACTION
public static final int FLAGS_RESPONSE
public static final int FLAGS2_NONE
public static final int FLAGS2_LONG_FILENAMES
public static final int FLAGS2_EXTENDED_ATTRIBUTES
public static final int FLAGS2_SECURITY_SIGNATURES
public static final int FLAGS2_EXTENDED_SECURITY_NEGOTIATION
public static final int FLAGS2_RESOLVE_PATHS_IN_DFS
public static final int FLAGS2_PERMIT_READ_IF_EXECUTE_PERM
public static final int FLAGS2_STATUS32
public static final int FLAGS2_UNICODE
public static final int CAP_NONE
public static final int CAP_RAW_MODE
public static final int CAP_MPX_MODE
public static final int CAP_UNICODE
public static final int CAP_LARGE_FILES
public static final int CAP_NT_SMBS
public static final int CAP_RPC_REMOTE_APIS
public static final int CAP_STATUS32
public static final int CAP_LEVEL_II_OPLOCKS
public static final int CAP_LOCK_AND_READ
public static final int CAP_NT_FIND
public static final int CAP_DFS
public static final int CAP_EXTENDED_SECURITY
public static final int FILE_READ_DATA
public static final int FILE_WRITE_DATA
public static final int FILE_APPEND_DATA
public static final int FILE_READ_EA
public static final int FILE_WRITE_EA
public static final int FILE_EXECUTE
public static final int FILE_DELETE
public static final int FILE_READ_ATTRIBUTES
public static final int FILE_WRITE_ATTRIBUTES
public static final int DELETE
public static final int READ_CONTROL
public static final int WRITE_DAC
public static final int WRITE_OWNER
public static final int SYNCHRONIZE
public static final int GENERIC_ALL
public static final int GENERIC_EXECUTE
public static final int GENERIC_WRITE
public static final int GENERIC_READ
public static final int FLAGS_TARGET_MUST_BE_FILE
public static final int FLAGS_TARGET_MUST_BE_DIRECTORY
public static final int FLAGS_COPY_TARGET_MODE_ASCII
public static final int FLAGS_COPY_SOURCE_MODE_ASCII
public static final int FLAGS_VERIFY_ALL_WRITES
public static final int FLAGS_TREE_COPY
public static final int OPEN_FUNCTION_FAIL_IF_EXISTS
public static final int OPEN_FUNCTION_OVERWRITE_IF_EXISTS
public static final int PID
public static final int SECURITY_SHARE
public static final int SECURITY_USER
public static final int CMD_OFFSET
public static final int ERROR_CODE_OFFSET
public static final int FLAGS_OFFSET
public static final int SIGNATURE_OFFSET
public static final int TID_OFFSET
public static final int HEADER_LENGTH
public static final long MILLISECONDS_BETWEEN_1970_AND_1601
public static final java.util.TimeZone TZ
public static final boolean USE_BATCHING
public static final java.lang.String OEM_ENCODING
public static final java.lang.String UNI_ENCODING
public static final int DEFAULT_FLAGS2
public static final int DEFAULT_CAPABILITIES
public static final int FLAGS2
public static final int CAPABILITIES
public static final boolean TCP_NODELAY
public static final int RESPONSE_TIMEOUT
public static final java.util.LinkedList CONNECTIONS
public static final int SSN_LIMIT
public static final int SO_TIMEOUT
public static final int CONN_TIMEOUT
public static final java.lang.String NATIVE_OS
public static final java.lang.String NATIVE_LANMAN
public static final int VC_NUMBER
public static final jcifs.smb.SmbTransport NULL_TRANSPORT
public SmbFile(java.lang.String url) throws java.net.MalformedURLException
url
- A URL stringjava.net.MalformedURLException
- If the parent
and child
parameters
do not follow the prescribed syntaxpublic SmbFile(SmbFile context, java.lang.String name) throws java.net.MalformedURLException, java.net.UnknownHostException
parent SmbFile
. See the description above for examples
of using the second name
parameter.context
- A base SmbFile
name
- A path string relative to the parent
paremeterjava.net.MalformedURLException
- If the parent
and child
parameters
do not follow the prescribed syntaxjava.net.UnknownHostException
- If the server or workgroup of the context file cannot be determinedpublic SmbFile(java.lang.String context, java.lang.String name) throws java.net.MalformedURLException
parent
. See the description above for examples of
using the second chile
parameter.context
- A URL stringname
- A path string relative to the context
paremeterjava.net.MalformedURLException
- If the context
and name
parameters
do not follow the prescribed syntaxpublic SmbFile(java.lang.String url, NtlmPasswordAuthentication auth) throws java.net.MalformedURLException
url
- A URL stringauth
- The credentials the client should use for authenticationjava.net.MalformedURLException
- If the url
parameter does not follow the prescribed syntaxpublic SmbFile(java.lang.String url, NtlmPasswordAuthentication auth, int shareAccess) throws java.net.MalformedURLException
url
- A URL stringauth
- The credentials the client should use for authenticationshareAccess
- Specifies what access other clients have while this file is open.java.net.MalformedURLException
- If the url
parameter does not follow the prescribed syntaxpublic SmbFile(java.lang.String context, java.lang.String name, NtlmPasswordAuthentication auth) throws java.net.MalformedURLException
context
. See the description above for examples of
using the second name
parameter.context
- A URL stringname
- A path string relative to the context
paremeterauth
- The credentials the client should use for authenticationjava.net.MalformedURLException
- If the context
and name
parameters
do not follow the prescribed syntaxpublic SmbFile(java.lang.String context, java.lang.String name, NtlmPasswordAuthentication auth, int shareAccess) throws java.net.MalformedURLException
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.context
- A URL stringname
- A path string relative to the context
paremeterauth
- The credentials the client should use for authenticationshareAccess
- Specifies what access other clients have while this file is open.java.net.MalformedURLException
- If the context
and name
parameters
do not follow the prescribed syntaxpublic SmbFile(SmbFile context, java.lang.String name, int shareAccess) throws java.net.MalformedURLException, java.net.UnknownHostException
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.context
- A base SmbFile
name
- A path string relative to the context
file pathshareAccess
- Specifies what access other clients have while this file is open.java.net.MalformedURLException
- If the context
and name
parameters
do not follow the prescribed syntaxjava.net.UnknownHostException
public SmbFile(java.net.URL url)
url
- The URL of the target resourcepublic SmbFile(java.net.URL url, NtlmPasswordAuthentication auth)
url
- The URL of the target resourceauth
- The credentials the client should use for authenticationpublic void connect() throws java.io.IOException
connect
in class java.net.URLConnection
java.io.IOException
public java.security.Principal getPrincipal()
public java.lang.String getName()
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.smb://
if the resource is smb://
itself.public java.lang.String getParent()
smb://
does not have a parent. In this case smb://
is returned.smb://
if the resource refers to the root of the URL
hierarchy which incedentally is also smb://
.public java.lang.String getPath()
SmbFile
constructed with the result of this method will
result in an SmbFile
that is equal to the original.public java.lang.String getUncPath()
public java.lang.String getCanonicalPath()
SmbFile
constructed with the result of
this method will result in an SmbFile
that is equal to
the original.public java.lang.String getShare()
smb://
, smb://workgroup/
,
and smb://server/
URLs which do not specify a share,
null
will be returned.null
if there is no sharepublic java.lang.String getServer()
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.null
if this
SmbFile
refers to the root smb://
resource.public int getType() throws SmbException
SmbException
public boolean exists() throws SmbException
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 or
false
otherwiseSmbException
public boolean canRead() throws SmbException
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-onlySmbException
public boolean canWrite() throws SmbException
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 marked
read-onlySmbException
public boolean isDirectory() throws SmbException
SmbFile
represents is a directory.true
if this SmbFile
is a directorySmbException
public boolean isFile() throws SmbException
SmbFile
represents is not a directory.true
if this SmbFile
is not a directorySmbException
public boolean isHidden() throws SmbException
IPC$
or C$
.true
if the SmbFile
is marked as being hiddenSmbException
public java.lang.String getDfsPath() throws SmbException
SmbFile
falls within a DFS volume,
this method will return the referral path to which it maps. Otherwise
null
is returned.SmbException
public long createTime() throws SmbException
SmbFile
was created. The value
returned is suitable for constructing a 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.long
valueSmbException
public long lastModified() throws SmbException
SmbFile
was modified. The value returned is suitable for
constructing a 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.long
valueSmbException
public java.lang.String[] list() throws SmbException
smb://
,
smb://workgroup/
URL,
smb://server/
,
null
if the resource cannot be resolved.
String[]
array of files and directories,
workgroups, servers, or shares depending on the context of the
resource URLSmbException
public java.lang.String[] list(SmbFilenameFilter filter) throws SmbException
list()
method minus filenames filtered by the specified filter.filter
- a filename filter to exclude filenames from the resultsSmbException
- # @return An array of filenamespublic SmbFile[] listFiles() throws SmbException
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 SmbFile
s returned by this method will be;
smb://
,
smb://workgroup/
URL,
smb://server/
,
null
if the resource cannot be resolved.
SmbFile
objects representing file
and directories, workgroups, servers, or shares depending on the context
of the resource URLSmbException
public SmbFile[] listFiles(java.lang.String wildcard) throws SmbException
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
wildcard
- a wildcard expressionSmbFile
objects representing file
and directories, workgroups, servers, or shares depending on the context
of the resource URLSmbException
public SmbFile[] listFiles(SmbFilenameFilter filter) throws SmbException
listFiles()
method minus files filtered by the specified filename filter.filter
- a filter to exclude files from the resultsSmbException
public SmbFile[] listFiles(SmbFileFilter filter) throws SmbException
listFiles()
method minus filenames filtered by the specified filter.filter
- a file filter to exclude files from the resultsSmbException
public void renameTo(SmbFile dest) throws SmbException
SmbFile
represents to the name
designated by the SmbFile
argument.
Remember: SmbFile
s 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.dest
- An SmbFile
that represents the new pathnamejava.lang.NullPointerException
- If the dest
argument is null
SmbException
public void copyTo(SmbFile dest) throws SmbException
dest
- the destination file or directorySmbException
public void delete() throws SmbException
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.SmbException
public long length() throws SmbException
SmbFile
is not a file.SmbException
public long getDiskFreeSpace() throws SmbException
SmbException
public void mkdir() throws SmbException
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).SmbException
public void mkdirs() throws SmbException
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).SmbException
public void createNewFile() throws SmbException
SmbException
public void setCreateTime(long time) throws SmbException
time
- the create time as milliseconds since Jan 1, 1970SmbException
public void setLastModified(long time) throws SmbException
time
- the last modified time as milliseconds since Jan 1, 1970SmbException
public int getAttributes() throws SmbException
SmbException
public void setAttributes(int attrs) throws SmbException
SmbException
public void setReadOnly() throws SmbException
SmbException
public void setReadWrite() throws SmbException
SmbException
public java.net.URL toURL() throws java.net.MalformedURLException
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).URL
for this SmbFile
java.net.MalformedURLException
public int hashCode()
SmbFile
objects that refer to
the same file should generate the same hashcode provided it is possible
to make such a determination.hashCode
in class java.lang.Object
SmbException
protected boolean pathNamesPossiblyEqual(java.lang.String path1, java.lang.String path2)
public boolean equals(java.lang.Object obj)
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
SmbFile
s that are equal.
smb://192.168.1.15/share/DIR/foo.txt smb://angus/share/data/../dir/foo.txt
equals
in class java.lang.Object
obj
- Another SmbFile
object to compare for equalitytrue
if the two objects refer to the same SMB resource
and false
otherwiseSmbException
public java.lang.String toString()
SmbFile
.
This method will return the same value
as getPath
.toString
in class java.net.URLConnection
SmbException
public int getContentLength()
getContentLength
in class java.net.URLConnection
public long getDate()
getDate
in class java.net.URLConnection
public long getLastModified()
getLastModified
in class java.net.URLConnection
public java.io.InputStream getInputStream() throws java.io.IOException
getInputStream
in class java.net.URLConnection
java.io.IOException
- thrown by SmbFileInputStream constructorpublic java.io.OutputStream getOutputStream() throws java.io.IOException
getOutputStream
in class java.net.URLConnection
java.io.IOException
- thrown by SmbFileOutputStream constructorpublic ACE[] getSecurity(boolean resolveSids) throws java.io.IOException
resolveSids
- Attempt to resolve the SIDs within each ACE form
their numeric representation to their corresponding account names.java.io.IOException
public ACE[] getShareSecurity(boolean resolveSids) throws java.io.IOException
Note that this is different from calling getSecurity on a share. There are actually two different ACLs for shares - the ACL on the share and the ACL on the folder being shared. Go to Computer Management > System Tools > Shared Folders > Shares and look at the Properties for a share. You will see two tabs - one for "Share Permissions" and another for "Security". These correspond to the ACLs returned by getShareSecurity and getSecurity respectively.
resolveSids
- Attempt to resolve the SIDs within each ACE form
their numeric representation to their corresponding account names.java.io.IOException
public ACE[] getSecurity() throws java.io.IOException
Initially, the SIDs within each ACE will not be resolved however when getType(), getDomainName(), getAccountName(), or toString() is called, the names will attempt to be resolved. If the names cannot be resolved (e.g. due to temporary network failure), the said methods will return default values (usually S-X-Y-Z strings of fragments of).
Alternatively getSecurity(true) may be used to resolve all SIDs together and detect network failures.
java.io.IOException