h DFTACTGRP(*NO) ACTGRP(*NEW)
d*
d* Define a field to store the String object we wish to trim
d string s O CLASS(*JAVA:'java.lang.String')
d*
d* Prototype the constructor for the String class. The
d* constructor expects a byte array.
d MakeString pr O EXTPROC(*JAVA:
d 'java.lang.String':
d *CONSTRUCTOR)
d CLASS(*JAVA:'java.lang.String') return type
d bytes 30A CONST VARYING
d*
d* Prototype the String method getBytes which converts a String to a byte
d* array. We can then store this byte array in an alpha field.
d GetBytes pr 30A EXTPROC(*JAVA:
d 'java.lang.String':
d 'getBytes') VARYING
d*
d* Prototype the String method trim. It doesnt take any parameters,
d* but since it is not a static method, must be called using a String
d* object.
d trimstring pr o EXTPROC(*JAVA:
d 'java.lang.String':
d 'trim')
d CLASS(*JAVA:'java.lang.String') return type
d*
d result s 30A inz(' 1234 5 ') varying
d*
C EVAL string = makestring(result)
C EVAL string = trimstring(string)
c eval result = GetBytes(string)
c result dsply
C*
C SETON LR
C RETURN
调用java的方法有什么好处,答案是:可以使用java的标准库。
当然也可以调用自己写的class,参照rpgle guide。
%2Fbooks_web%2Fc0925076172.htm
阅读(1174) | 评论(0) | 转发(1) |