Package jcifs
Class Config
java.lang.Object
jcifs.Config
This class uses a static
Properties
to act
as a cental repository for all jCIFS configuration properties. It cannot be
instantiated. Similar to System
properties the namespace
is global therefore property names should be unique. Before use,
the load
method should be called with the name of a
Properties
file (or null
indicating no
file) to initialize the Config
. The System
properties will then populate the Config
as well potentially
overwriting properties from the file. Thus properties provided on the
commandline with the -Dproperty.name=value
VM parameter
will override properties from the configuration file.
There are several ways to set jCIFS properties. See the overview page of the API documentation for details.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Object
Retrieve a property as anObject
.static boolean
getBoolean
(String key, boolean def) Retrieve a boolean value.static InetAddress
getInetAddress
(String key, InetAddress def) Retrieve anInetAddress
.static InetAddress[]
getInetAddressArray
(String key, String delim, InetAddress[] def) Retrieve an array of InetAddress created from a property value containting a delim separated list of hostnames and/or ipaddresses.static int
Retrieve anint
.static int
Retrieve anint
.static InetAddress
static long
Retrieve along
.static String
getProperty
(String key) Retrieve aString
.static String
getProperty
(String key, String def) Retrieve aString
.static void
list
(PrintStream out) List the properties in theCode
.static void
load
(InputStream in) Load theConfig
with properties from the streamin
from aProperties
file.static void
This static method registers the SMB URL protocol handler which is required to use SMB URLs with the java.net.URL class.static void
setProperties
(Properties prp) Set the default properties of the static Properties used by Config.static Object
setProperty
(String key, String value) Add a property.static void
store
(OutputStream out, String header)
-
Field Details
-
socketCount
public static int socketCount -
DEFAULT_OEM_ENCODING
-
-
Method Details
-
registerSmbURLHandler
public static void registerSmbURLHandler()This static method registers the SMB URL protocol handler which is required to use SMB URLs with the java.net.URL class. If this method is not called before attempting to create an SMB URL with the URL class the following exception will occur:Exception MalformedURLException: unknown protocol: smb at java.net.URL.
(URL.java:480) at java.net.URL. (URL.java:376) at java.net.URL. (URL.java:330) at jcifs.smb.SmbFile. (SmbFile.java:355) ... -
setProperties
Set the default properties of the static Properties used by Config. This permits a different Properties object/file to be used as the source of properties for use by the jCIFS library. The Properties must be set before jCIFS classes are accessed as most jCIFS classes load properties statically once. Using this method will also override properties loaded using the -Djcifs.properties= commandline parameter. -
load
Load theConfig
with properties from the streamin
from aProperties
file.- Throws:
IOException
-
store
- Throws:
IOException
-
list
List the properties in theCode
.- Throws:
IOException
-
setProperty
Add a property. -
get
Retrieve a property as anObject
. -
getProperty
Retrieve aString
. If the key cannot be found, the provideddef
default parameter will be returned. -
getProperty
Retrieve aString
. If the property is not found,null
is returned. -
getInt
Retrieve anint
. If the key does not exist or cannot be converted to anint
, the provided default argument will be returned. -
getInt
Retrieve anint
. If the property is not found,-1
is returned. -
getLong
Retrieve along
. If the key does not exist or cannot be converted to along
, the provided default argument will be returned. -
getInetAddress
Retrieve anInetAddress
. If the address is not an IP address and cannot be resolvednull
will be returned. -
getLocalHost
-
getBoolean
Retrieve a boolean value. If the property is not found, the value ofdef
is returned. -
getInetAddressArray
Retrieve an array of InetAddress created from a property value containting a delim separated list of hostnames and/or ipaddresses.
-