I have troubles using the java.io.BufferedReader.read(char[] cbuf, int off, int len) method in MATLAB because of MATLAB's automatic conversion of Java's built-in variables (boolean, byte, short, long, int, double, float, and char) to MATLAB variables.
I can not pass a MATLAB char Array to the read method:
cbuf= =char(1:1024);
bufleng= BufferedReader.read(cbuf, 0, 1024);
Since MATLAB arrays are passed by value and any changes that a Java method makes to them are not visible to the MATLAB code. However, I need to access the changes to cbuf of the read() method.
In such a case it is suggested to creat (with MATLAB's javaArray command) a Java Array, rather than passing a MATLAB array. MATLAB's javaArray command does not support the built-in Java types and it's therefore impossible to creat a Java char array.
I bypassed this by creating a Java String Array, which I converter to a CharArray in a second step:
s= javaObject('java.lang.String', 'sdsdfsd');
charar= javaMethod('toCharArray',s)
Sadly MATLAB converts the returned Java char Array automaticlly into an MATLAB char Array.
To avoid this conversion I tried to interlace the methods in each other:
s= javaObject('java.lang.String', 'sdsdfsd');
buflen= javaMethod('read', BufferedReader, javaMethod('toCharArray',s),0,
1024);
It doesn't work either. Does somebody has a idea how to solve this problem? I would appreciate your guys help a lot!
Michael
I think the BufferedReader cannot be used in the way you described below... It takes a Reader object... So you should try:
>> s = java.lang.String('sdsdfsd');
>> cr = java.io.CharArrayReader(s.toCharArray,0,1024);
>> br = java.io.BufferedReader(cr);
Hope this works...
Ed.
"Michael " <michael.s...@hs-furtwangen.de> wrote in message <idp7ut$dai$1...@fred.mathworks.com>...