ClassNotFoundException in serialization code

I wrote out a data file using a Java class that implement java.io.Serializable. When I tried to read the file in MATLAB, there are "Java exception occurred: java.lang.ClassNotFoundException: com/mycompany/matlabtest/TestData$DataType"
I added the jar file to the MATLAB using javaaddpath.
The code I used to read it is fin = java.io.FileInputStream('C:\matlabtest.dat'); ois = java.io.ObjectInputStream(fin); dtype = ois.readObject();
Is it possible for me to read the proprietary file? I can change the Java code that creates the files. Thanx.

답변 (1개)

Ching
Ching 2011년 9월 14일

0 개 추천

I don't know if this means anything, but I can create the Java object (the type that the readObject() command I expected to return) in MATLAB by using the following command:
newobj= javaMethod('valueOf','com.mycompany.matlabtest.TestData$DataType','SINGLE');

카테고리

도움말 센터File Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기

질문:

2011년 9월 14일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by