Package jcifs
Class Config
- java.lang.Object
-
- jcifs.Config
-
public class Config extends java.lang.Object
This class uses a staticProperties
to act as a cental repository for all jCIFS configuration properties. It cannot be instantiated. Similar toSystem
properties the namespace is global therefore property names should be unique. Before use, theload
method should be called with the name of aProperties
file (ornull
indicating no file) to initialize theConfig
. TheSystem
properties will then populate theConfig
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 Modifier and Type Field Description static java.lang.String
DEFAULT_OEM_ENCODING
static int
socketCount
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object
get(java.lang.String key)
Retrieve a property as anObject
.static boolean
getBoolean(java.lang.String key, boolean def)
Retrieve a boolean value.static java.net.InetAddress
getInetAddress(java.lang.String key, java.net.InetAddress def)
Retrieve anInetAddress
.static java.net.InetAddress[]
getInetAddressArray(java.lang.String key, java.lang.String delim, java.net.InetAddress[] def)
Retrieve an array of InetAddress created from a property value containting a delim separated list of hostnames and/or ipaddresses.static int
getInt(java.lang.String key)
Retrieve anint
.static int
getInt(java.lang.String key, int def)
Retrieve anint
.static java.net.InetAddress
getLocalHost()
static long
getLong(java.lang.String key, long def)
Retrieve along
.static java.lang.String
getProperty(java.lang.String key)
Retrieve aString
.static java.lang.String
getProperty(java.lang.String key, java.lang.String def)
Retrieve aString
.static void
list(java.io.PrintStream out)
List the properties in theCode
.static void
load(java.io.InputStream in)
Load theConfig
with properties from the streamin
from aProperties
file.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.static void
setProperties(java.util.Properties prp)
Set the default properties of the static Properties used by Config.static java.lang.Object
setProperty(java.lang.String key, java.lang.String value)
Add a property.static void
store(java.io.OutputStream out, java.lang.String header)
-
-
-
Method Detail
-
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
public static void setProperties(java.util.Properties prp)
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
public static void load(java.io.InputStream in) throws java.io.IOException
Load theConfig
with properties from the streamin
from aProperties
file.- Throws:
java.io.IOException
-
store
public static void store(java.io.OutputStream out, java.lang.String header) throws java.io.IOException
- Throws:
java.io.IOException
-
list
public static void list(java.io.PrintStream out) throws java.io.IOException
List the properties in theCode
.- Throws:
java.io.IOException
-
setProperty
public static java.lang.Object setProperty(java.lang.String key, java.lang.String value)
Add a property.
-
get
public static java.lang.Object get(java.lang.String key)
Retrieve a property as anObject
.
-
getProperty
public static java.lang.String getProperty(java.lang.String key, java.lang.String def)
Retrieve aString
. If the key cannot be found, the provideddef
default parameter will be returned.
-
getProperty
public static java.lang.String getProperty(java.lang.String key)
Retrieve aString
. If the property is not found,null
is returned.
-
getInt
public static int getInt(java.lang.String key, int def)
Retrieve anint
. If the key does not exist or cannot be converted to anint
, the provided default argument will be returned.
-
getInt
public static int getInt(java.lang.String key)
Retrieve anint
. If the property is not found,-1
is returned.
-
getLong
public static long getLong(java.lang.String key, long def)
Retrieve along
. If the key does not exist or cannot be converted to along
, the provided default argument will be returned.
-
getInetAddress
public static java.net.InetAddress getInetAddress(java.lang.String key, java.net.InetAddress def)
Retrieve anInetAddress
. If the address is not an IP address and cannot be resolvednull
will be returned.
-
getLocalHost
public static java.net.InetAddress getLocalHost()
-
getBoolean
public static boolean getBoolean(java.lang.String key, boolean def)
Retrieve a boolean value. If the property is not found, the value ofdef
is returned.
-
getInetAddressArray
public static java.net.InetAddress[] getInetAddressArray(java.lang.String key, java.lang.String delim, java.net.InetAddress[] def)
Retrieve an array of InetAddress created from a property value containting a delim separated list of hostnames and/or ipaddresses.
-
-