[tcljava-user] Help with reading data into a byte array in tclblend
Brought to you by:
mdejong
|
From: Ross, B. <Bil...@Ca...> - 2010-04-14 21:02:17
|
I am new to Java but have doing TCL for many years.
I have one application that requires java.
I have gotten it all working but am now trying to add a new feature.
I get an object "cstat" back using tclbelnd.
According to the Javadoc I need to read it back into a byte array.
I then want to write it to a file using "$fos {write byte[]}
$dataBytes;"
I can't figure out the right syntax in tclblend to do this.
I can use a different Java command to get the size of the file which is
3188.
I tried creating a byte array of this size .
Any help would be appreciated.
Here is the line from the javadoc that shows the Java code that does the
data
byte[] bytes = (byte[])cstat.getData();
Here is the relevant tclblend code I tried
set fos [java::new java.io.FileOutputStream
"/home/server/output/filename"];
set dataBytes [java::new {byte[]} 3188];
set dataBytes [$cstat getData];
$fos {write byte[]} $dataBytes;
$fos close;
When I run my code I get
expected object of type byte[] but got "java0xc" (java.lang.Object)
while executing
"$fos {write byte[]} $dataBytes"
|