Created
January 5, 2012 15:13
-
-
Save StefanKrecher/1565660 to your computer and use it in GitHub Desktop.
Ambrhino (Smalltalk/Amber-, Java-, Javascript-Mixture) example: makes HTTP-GET-Request & display result on a JFrame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| url con is isr br line content pane frame | | |
<importPackage(java.net)>. | |
<importPackage(java.io)>. | |
url := <new URL('http://www.esvapi.org/v2/rest/passageQuery?key=IP&passage=Psalm+23&include-headings=false')>. | |
con := url openConnection. | |
is := con getInputStream. | |
isr := <new InputStreamReader(is)>. | |
br := <new BufferedReader(isr)>. | |
content := ''. | |
line := ''. | |
[ line isNil ] whileFalse: [ | |
line := br readLine. | |
content := content, line. | |
]. | |
pane := <new JTextPane()>. | |
pane setContentType: 'text/html'. | |
pane setText: (content printString). | |
frame := <new JFrame()>. | |
frame getContentPane add: pane. | |
frame pack; setVisible: true. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment