Please, if you don't care for Cookie - just DO use urlread!!! I DO mean it!
The only working way was to use Ice(Java) functions in Matlab, which are NOT documented in any way. Therefore one needs to experiment a lot with them!
So if you are not scared yet, here we go:
To read binary data use:
uint8( DataInputStream.read() )
To get cookie use:
CookieString = char(HttpURLConnection.getCookieManager().elements.nextElement.Cookie.toString)
or the following might also work
CookieString = char(HttpURLConnection.getCookieManager().getHeaderField('Set-Cookie') )
To set cookie use:
HttpURLConnection.setRequestProperty('Cookie', CookieString )
Since i am by no means an expert neither in Java nor in Matlab i might have overlooked something. Please do let me know if you know a better way.
ps: of course you start as follows:
URL = java.net.URL('http://example.url');
HttpURLConnection = URL.openConnection();
Hi,
ReplyDeleteI tried some of your code in a Matlab command window, and I think a bunch of stuff needs to be set for this to work. Do you have the full program available?
Yours,
Raj
>> CookieString = char(HttpURLConnection.getCookieManager().elements.nextElement.Cookie.toString)
??? Undefined variable "HttpURLConnection" or class
"HttpURLConnection.getCookieManager".
>>
thanks, i added a postscriptum about how to get that HttpURLConnection.
ReplyDeleteIf there will be a confusion with a type name - just rename that variable 'HttpURLConnection' into something else and use it afterwards.