|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jcifs.smb.SmbFile
This class represents a file or directory on an SMB file server. All
methods should operate identically to those of the File
class. One fundamental difference is the usage of a URL to specify the
location of a file or diectory. All SmbFile URLs have the following
syntax:
smb://[[domain;]username[:password]@]hostname[:port]/share[/path]Examples:
smb://users-nyc;msmith:PaSsW#Rd@storage15/docs/oct/YahooEarnings887.doc smb://Administrator:Fo0BarP@ss@msmith1/c/WINDOWS/Desktop/YHOO Reports.txt smb://storage15/publicIf may also be necessary to specify properties for jcifs to function correctly. See Setting JCIFS Properties for details.
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 as '/' at the beginning of the second
parameter will still use the same host. The examples below illustrate
the resulting URLs when this second contructor argument is used.
Examples:
base relative 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/foo + ../../othershare --> smb://host/othershare smb://host/share/zig/zag + /othershare --> smb://host/othershare smb://host/share/zig/zag + smb://foo/bar --> smb://foo/bar smb://host/share/zig/zag + null --> smb://host/share/zig/zag smb://host/share/zig/zag + / --> <exception: at least share must be specified>Instances of the
SmbFile
class are immutable; that is,
once created, the abstract pathname represented by an SmbFile object
will never change.
Constructor Summary | |
SmbFile(SmbFile file,
String name)
Constructs an SmbFile representing a file or directory on an SMB server specified by the SmbFile augmented with the named path. |
|
SmbFile(String url)
Constructs and SmbFile representing a file or directory on an SMB server specified by the URL argument. |
|
SmbFile(String url,
String name)
Constructs an SmbFile representing a file or directory on an SMB server specified by the URL argument and the possibly null relative path. |
Method Summary | |
boolean |
canRead()
Tests to see if the file this SmbFile represents is marked read-only. |
boolean |
canWrite()
Tests to see if the file this SmbFile represents is not marked read-only. |
boolean |
delete()
Deletes the file on the SMB server that this SmbFile represents. |
boolean |
equals(Object obj)
Tests to see if two SmbFile objects are equal by comparing hashCodes. |
boolean |
exists()
Tests to see if the file this SmbFile represents exists on the server. |
String |
getCanonicalPath()
Returns the full URL with '..' and '.' components factored out. |
String |
getName()
Returns the last component of the path. |
String |
getParent()
Returns everything but the last component of the path. |
String |
getPath()
Returns the full URL. |
int |
hashCode()
Computes a hashCode for this file based on the URL string. |
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 being hidden. |
long |
lastModified()
Returns the time the file this SmbFile represents was lastModified. |
long |
length()
Returns the length of the file this SmbFile represents. |
String[] |
list()
Returns the names of files and directorys listed under the directory this SmbFile represents. |
boolean |
mkdir()
Creates a directory with the path specified by this SmbFile. |
boolean |
renameTo(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). |
String |
toString()
Returns the string representation of this SmbFile object. |
URL |
toURL()
Returns the URL representation of the file this SmbFile represents. |
Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public SmbFile(String url) throws MalformedURLException, UnknownHostException
public SmbFile(String url, String name) throws MalformedURLException, UnknownHostException
public SmbFile(SmbFile file, String name) throws MalformedURLException, UnknownHostException
Method Detail |
public String getName()
public String getParent()
public String getPath()
public String getCanonicalPath()
public boolean exists()
public boolean canRead()
public boolean canWrite()
public boolean isDirectory()
public boolean isFile()
public boolean isHidden()
public long lastModified()
public String[] list()
public boolean renameTo(SmbFile dest)
public boolean delete()
public long length()
public boolean mkdir()
public URL toURL() throws MalformedURLException
public int hashCode()
public boolean equals(Object obj)
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |