To read from a File you can do this:
byte[] keyBytes = (byte[]) AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
try {
File f = new File("<path>\\private.der");
FileInputStream fis = new FileInputStream(f);
DataInputStream dis = new DataInputStream(fis);
byte[] keyBytes = new byte[(int) f.length()];
dis.readFully(keyBytes);
dis.close();
return keyBytes;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
});
And then you can read the file and get the content as a byte array