Package jcifs.smb1
Class Config
- java.lang.Object
-
- jcifs.smb1.Config
-
public class Config extends Object
This class uses a staticPropertiesto act as a cental repository for all jCIFS configuration properties. It cannot be instantiated. Similar toSystemproperties the namespace is global therefore property names should be unique. Before use, theloadmethod should be called with the name of aPropertiesfile (ornullindicating no file) to initialize theConfig. TheSystemproperties will then populate theConfigas well potentially overwriting properties from the file. Thus properties provided on the commandline with the-Dproperty.name=valueVM 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 StringDEFAULT_OEM_ENCODINGstatic intsocketCount
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Objectget(String key)Retrieve a property as anObject.static booleangetBoolean(String key, boolean def)Retrieve a boolean value.static InetAddressgetInetAddress(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 intgetInt(String key)Retrieve anint.static intgetInt(String key, int def)Retrieve anint.static InetAddressgetLocalHost()static longgetLong(String key, long def)Retrieve along.static StringgetProperty(String key)Retrieve aString.static StringgetProperty(String key, String def)Retrieve aString.static voidlist(PrintStream out)List the properties in theCode.static voidload(InputStream in)Load theConfigwith properties from the streaminfrom aPropertiesfile.static voidregisterSmbURLHandler()This static method registers the SMB URL protocol handler which is required to use SMB URLs with the java.net.URL class.static voidsetProperties(Properties prp)Set the default properties of the static Properties used by Config.static ObjectsetProperty(String key, String value)Add a property.static voidstore(OutputStream out, String header)
-
-
-
Field Detail
-
socketCount
public static int socketCount
-
DEFAULT_OEM_ENCODING
public static String DEFAULT_OEM_ENCODING
-
-
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.smb1.smb1.SmbFile. (SmbFile.java:355) ...
-
setProperties
public static void setProperties(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(InputStream in) throws IOException
Load theConfigwith properties from the streaminfrom aPropertiesfile.- Throws:
IOException
-
store
public static void store(OutputStream out, String header) throws IOException
- Throws:
IOException
-
list
public static void list(PrintStream out) throws IOException
List the properties in theCode.- Throws:
IOException
-
getProperty
public static String getProperty(String key, String def)
Retrieve aString. If the key cannot be found, the provideddefdefault parameter will be returned.
-
getProperty
public static String getProperty(String key)
Retrieve aString. If the property is not found,nullis returned.
-
getInt
public static int getInt(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(String key)
Retrieve anint. If the property is not found,-1is returned.
-
getLong
public static long getLong(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 InetAddress getInetAddress(String key, InetAddress def)
Retrieve anInetAddress. If the address is not an IP address and cannot be resolvednullwill be returned.
-
getLocalHost
public static InetAddress getLocalHost()
-
getBoolean
public static boolean getBoolean(String key, boolean def)
Retrieve a boolean value. If the property is not found, the value ofdefis returned.
-
getInetAddressArray
public 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.
-
-