this method return information about default device
devices = new Properties();
FileInputStream fstream = AccessController
.doPrivileged(new PrivilegedAction<FileInputStream>() {
public FileInputStream run() {
// obtain the path to the file sound.properties
String soundPropertiesPath = System
.getProperty("java.home") //$NON-NLS-1$
+ File.separator + "lib" + File.separator //$NON-NLS-1$
+ "sound.properties"; //$NON-NLS-1$
try {
return new FileInputStream(soundPropertiesPath);
} catch (FileNotFoundException e) {
return null;
}
}
});
if (fstream != null) {
// reading file sound.properties
try {
devices.load(fstream);
} catch (IOException e) {}
}
// variable that contain information about default device
List<String> defaultDevice = new ArrayList<String>();
String str;
int index;
/*
* obtain the default device that describes by deviceName
*/
str = devices.getProperty(deviceName);
/*
* if default device doesn't define, than return empty defaultDevice
*/
if (str == null) {
return defaultDevice;
}
/*
* the separator between provider and name is '#'; find separator of
* provider and name of device in the notation of default device
*/
index = str.indexOf("#"); //$NON-NLS-1$
/*
* if separator doesn't find, so in the definition of default device
* contain only name of provider, and so we add it
*/
if (index == -1) {
defaultDevice.add(str);
defaultDevice.add(null);
/*
* if separator is the first symbol, so definition contain only name
* of device
*/
} else if (index == 0) {
defaultDevice.add(null);
defaultDevice.add(str.substring(index + 1));
/*
* if separator is not the first, so we find provider and name of
* device
*/
} else {
defaultDevice.add(str.substring(0, index));
defaultDevice.add(str.substring(index + 1));
}
return defaultDevice;