java.util.prefs.Preferences getByteArray(String key, byte[] def)
NullPointerException not thrown when key =null
Test program :
-------------
import java.util.prefs.*;
import java.util.*;
public class GetByteArrayTest {
public static void main(String[] args) throws Exception {
try {
Preferences userRoot = Preferences.userRoot();
Preferences N1 = userRoot.node("N1");
N1.clear();
byte [] value = new byte[1];
value[0]=(byte)2;
N1.putByteArray("k1",value);
byte[] valueExpected = value;
byte[] valuedefault = new byte[1];
valuedefault[0] = (byte)0;
byte[] valueGot = N1.getByteArray(null,valuedefault);
System.out.println("NullPointerException not thrown valueGot[0] = " + valueGot[0]);
} catch(NullPointerException npe) {
System.out.println("Expected NullPointerException thrown = " + npe);
System.out.println("GetByteArrayTestTest02() Pass");
} catch(Exception e) {
System.out.println("Exception thrown = " + e);
System.out.println("GetByteArrayTestTest02() Fail");
e.printStackTrace();
}
}
}
NullPointerException not thrown when key =null
Test program :
-------------
import java.util.prefs.*;
import java.util.*;
public class GetByteArrayTest {
public static void main(String[] args) throws Exception {
try {
Preferences userRoot = Preferences.userRoot();
Preferences N1 = userRoot.node("N1");
N1.clear();
byte [] value = new byte[1];
value[0]=(byte)2;
N1.putByteArray("k1",value);
byte[] valueExpected = value;
byte[] valuedefault = new byte[1];
valuedefault[0] = (byte)0;
byte[] valueGot = N1.getByteArray(null,valuedefault);
System.out.println("NullPointerException not thrown valueGot[0] = " + valueGot[0]);
} catch(NullPointerException npe) {
System.out.println("Expected NullPointerException thrown = " + npe);
System.out.println("GetByteArrayTestTest02() Pass");
} catch(Exception e) {
System.out.println("Exception thrown = " + e);
System.out.println("GetByteArrayTestTest02() Fail");
e.printStackTrace();
}
}
}