try {
RemoteStub stub = (RemoteStub) toStub(this);
FileOutputStream file = new FileOutputStream("C:\\temp\\ping_stub");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(file);
objectOutputStream.writeObject(stub);
objectOutputStream.close();
} catch (Exception e) {
System.out.println("Error writing stub to file");
e.printStackTrace();
}