octave-task-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-task-tracker] [task #12601] Octave/Matlab differences regarding


From: Rik
Subject: [Octave-task-tracker] [task #12601] Octave/Matlab differences regarding Java
Date: Thu, 01 May 2014 22:26:14 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0

Follow-up Comment #3, task #12601 (project octave):

Another useful thing to add would be load/save support for Java objects.  This
would require providing implementations for the virtual functions save_binary
and load_binary in ov-java.cc.

A very reasonable approach would be to call the Serialize method of the java
object itself and then just store the data.

I just tried this and it worked out fine:


x = javaObject ('java.lang.Double', pi)
fout = javaObject('java.io.FileOutputStream', '/tmp/blah.ser')
sout = javaObject ('java.io.ObjectOutputStream', fout)
sout.writeObject (x)
sout.close ()
fin = javaObject('java.io.FileInputStream', '/tmp/blah.ser')
sin = javaObject ('java.io.ObjectInputStream', fin)
xin = sin.readObject
xin
sin.close ()
fin = javaObject('java.io.FileInputStream', '/tmp/blah.ser')
sin = javaObject ('java.io.ObjectInputStream', fin)
xin2 = javaObject ('java.lang.Double', sin.readObject())
xin2.toString


The first time I read the object it just returned a double of 3.1416.  I think
this is probably caused by Octave auto-converting the result from a Java
object to a double.  The second time I called the Java constructor with the
results of the readObject call and it returned a true Java object with the
full value of pi.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/task/?12601>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]