JavaGetByteArray Function

Action

Retrieves the byte array return value of the last call of JavaCallMethod on the specified object or class.

Include file

JavaBase.bdh

Syntax

JavaGetByteArray(
    in  hObject : number,
    out sBuffer : string,
    in nBufLen : number optional );
Parameter Description
hObject Valid handle to a java object or JAVA_STATIC_METHOD.
sBuffer String buffer that will receive the return value of the last call of JavaCallMethod.
nBufLen Length of the buffer (optional).

Example

benchmark SampleDocu
use "Kernel.bdh"
use "Java.bdh"                

// Workload Section
dcluser   
  user
    JavaUser

  transactions
    TInit               : begin;      
    TMyJavaTrans        : 1;

// Java Framework Transactions Section
dcltrans
  transaction TInit
  begin    
    JavaCreateJavaVM();
  end TInit;

  transaction TMyJavaTrans
  var
    hStr    : number;
    sBuffer : string;
  begin
                           
    // creating a Java string
    hStr := JavaLoadString("a sample string containing a currency symbol €");
    // getting bytes array
    JavaCallMethod(hStr, "getBytes");
    // storing byte array
    JavaGetByteArray(hStr, sBuffer);
    // print to virtual user output
    Print(sBuffer);
  end TMyJavaTrans;