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

sample[jx8-android] fileContents from URL

"Reading from a URLConnection"
| url connection reader result |
url := URL from: 'http://www.smalltalking.net/'.
connection := url openConnection.
[ connection inputStream
] on: Error do: [:ex|
	self print: 'Exception thrown, this method should NOT be running in main thread'.
	ex javaException printStackTrace
].
connection inputStream reader buffered linesDo: [:line|
	result := result isNil ifTrue: [ line ]
		ifFalse: [ result ,'
'			,line ]
].
result.
self print: 'result size=' ,result size.


References

See also: