[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[jx8-android] 013 - Arguments

"Instantiating and passing objects"
| dataArray data stream reader bufferedReader |
dataArray := 'hello world\n' asArray
    collect: [:c| Java current newByte: c asciiValue ].
data := Java current
    newArray: #byte
    withAll: (dataArray collect: [:each| each json ]).
self print: 'data=' ,data toString.

stream := Java current newInstanceSync: 'java.io.ByteArrayInputStream' with: data.
self print: 'stream=' ,stream toString.

reader := Java current newInstanceSync: 'java.io.InputStreamReader' with: stream.
self print: 'reader=' ,reader toString.

bufferedReader := Java current newInstanceSync: 'java.io.BufferedReader' with: reader.
self print: 'bufferedReader readLine=' ,bufferedReader handle readLine.